summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritojun <itojun@openbsd.org>2001-07-25 17:41:06 +0000
committeritojun <itojun@openbsd.org>2001-07-25 17:41:06 +0000
commitb29cfae3972d0c26f54428bf0889bf7c9dab4430 (patch)
tree22179d7de6d293acfea41d702a3bbe5d394eaa26
parentremove local hack (diff)
downloadwireguard-openbsd-b29cfae3972d0c26f54428bf0889bf7c9dab4430.tar.xz
wireguard-openbsd-b29cfae3972d0c26f54428bf0889bf7c9dab4430.zip
do not write into s6_addr[16] (out of bounds).
-rw-r--r--sbin/ifconfig/ifconfig.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 020d84192af..c9414be532d 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.49 2001/07/07 18:26:13 deraadt Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.50 2001/07/25 17:41:06 itojun Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -81,7 +81,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else
-static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.49 2001/07/07 18:26:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.50 2001/07/25 17:41:06 itojun Exp $";
#endif
#endif /* not lint */
@@ -1942,7 +1942,8 @@ in_getprefix(plen, which)
memset((void *)&sin->sin_addr, 0x00, sizeof(sin->sin_addr));
for (cp = (u_char *)&sin->sin_addr; len > 7; len -= 8)
*cp++ = 0xff;
- *cp = 0xff << (8 - len);
+ if (len)
+ *cp = 0xff << (8 - len);
}
/*
@@ -2047,7 +2048,8 @@ in6_getprefix(plen, which)
memset((void *)&sin->sin6_addr, 0x00, sizeof(sin->sin6_addr));
for (cp = (u_char *)&sin->sin6_addr; len > 7; len -= 8)
*cp++ = 0xff;
- *cp = 0xff << (8 - len);
+ if (len)
+ *cp = 0xff << (8 - len);
}
int