summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2014-07-11 15:28:28 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2014-07-11 15:28:28 +0000
commit0169f2b1413dc356ea293cf729dcd06c6cfa05cc (patch)
treed8494be0c015a1e36bd3e2d40aa34bb068581f24 /sbin
parentb3cce4b6a8523c1ef3eb19fb987162bc362b1ced (diff)
Silence a compiler warning and build with -Wall etc.
While here check that our buffer is big enough. OK benno@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ping6/Makefile8
-rw-r--r--sbin/ping6/ping6.c12
2 files changed, 12 insertions, 8 deletions
diff --git a/sbin/ping6/Makefile b/sbin/ping6/Makefile
index 3a63793de72..b4d6f104895 100644
--- a/sbin/ping6/Makefile
+++ b/sbin/ping6/Makefile
@@ -1,6 +1,12 @@
-# $OpenBSD: Makefile,v 1.10 2013/04/16 16:51:36 deraadt Exp $
+# $OpenBSD: Makefile,v 1.11 2014/07/11 15:28:27 florian Exp $
PROG= ping6
+
+CFLAGS+= -Wall
+CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS+= -Wmissing-declarations
+CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
+
MAN= ping6.8
LDADD= -lm
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index edb0a88a92f..ca35606c9fa 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping6.c,v 1.98 2014/07/11 15:25:48 florian Exp $ */
+/* $OpenBSD: ping6.c,v 1.99 2014/07/11 15:28:27 florian Exp $ */
/* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
/*
@@ -1739,18 +1739,16 @@ pr_nodeaddr(struct icmp6_nodeinfo *ni, int nilen)
*/
if (nilen % (sizeof(u_int32_t) + sizeof(struct in6_addr)) == 0)
withttl = 1;
- while (nilen > 0) {
- u_int32_t ttl;
+ while (nilen >= sizeof(struct in6_addr)) {
+ u_int32_t ttl = (u_int32_t)ntohl(*(u_int32_t *)cp);
if (withttl) {
- /* XXX: alignment? */
- ttl = (u_int32_t)ntohl(*(u_int32_t *)cp);
cp += sizeof(u_int32_t);
nilen -= sizeof(u_int32_t);
}
- if (inet_ntop(AF_INET6, cp, ntop_buf, sizeof(ntop_buf)) ==
- NULL)
+ if (nilen < sizeof(struct in6_addr) || inet_ntop(AF_INET6,
+ cp, ntop_buf, sizeof(ntop_buf)) == NULL)
strncpy(ntop_buf, "?", sizeof(ntop_buf));
printf(" %s", ntop_buf);
if (withttl) {