diff options
author | 2014-07-11 15:28:27 +0000 | |
---|---|---|
committer | 2014-07-11 15:28:27 +0000 | |
commit | b8d965d2c98039b116e07086297bfc56b5974aae (patch) | |
tree | 4f958a27ba0aab79ba8526fa9ca9a7e8116560ad | |
parent | OPENSSL_ALGORITHM_DEFINES has been removed from conf.h, no need for it now (diff) | |
download | wireguard-openbsd-b8d965d2c98039b116e07086297bfc56b5974aae.tar.xz wireguard-openbsd-b8d965d2c98039b116e07086297bfc56b5974aae.zip |
Silence a compiler warning and build with -Wall etc.
While here check that our buffer is big enough.
OK benno@
-rw-r--r-- | sbin/ping6/Makefile | 8 | ||||
-rw-r--r-- | sbin/ping6/ping6.c | 12 |
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) { |