diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2014-09-13 10:10:29 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-09-16 09:04:16 +1000 |
commit | ea5509237291f1a109d46052353ece197f4213bc (patch) | |
tree | 3665fb2b4dbcbee9ebe7f7d5ca9c9b704135cd37 | |
parent | 3b016908924afb5ef71ac874bedf8c6f0157941c (diff) | |
download | glibc-ea5509237291f1a109d46052353ece197f4213bc.zip glibc-ea5509237291f1a109d46052353ece197f4213bc.tar.gz glibc-ea5509237291f1a109d46052353ece197f4213bc.tar.bz2 |
Handle zero prefix length in getifaddrs (BZ #17371)
(cherry picked from commit a7b872687073decdcc7effc2289877d69058aca9)
Conflicts:
NEWS
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ifaddrs.c | 11 |
3 files changed, 16 insertions, 7 deletions
@@ -1,3 +1,9 @@ +2014-09-15 Andreas Schwab <schwab@linux-m68k.org> + + [BZ #17371] + * sysdeps/unix/sysv/linux/ifaddrs.c (getifaddrs_internal): Fix + last change to handle zero prefix length. + 2014-09-12 Joseph Myers <joseph@codesourcery.com> * sysdeps/gnu/netinet/udp.h (UDP_NO_CHECK6_TX): New macro. @@ -5,6 +5,12 @@ See the end for copying conditions. Please send GNU C library bug reports via <http://sourceware.org/bugzilla/> using `glibc' in the "product" field. +Version 2.20.1 + +* The following bugs are resolved with this release: + + 17371. + Version 2.20 * The following bugs are resolved with this release: diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index 2c04e17..a47b2ed 100644 --- a/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/sysdeps/unix/sysv/linux/ifaddrs.c @@ -770,20 +770,17 @@ getifaddrs_internal (struct ifaddrs **ifap) if (cp != NULL) { - char c; unsigned int preflen; - if ((max_prefixlen > 0) && - (ifam->ifa_prefixlen > max_prefixlen)) + if (ifam->ifa_prefixlen > max_prefixlen) preflen = max_prefixlen; else preflen = ifam->ifa_prefixlen; - for (i = 0; i < ((preflen - 1) / 8); i++) + for (i = 0; i < preflen / 8; i++) *cp++ = 0xff; - c = 0xff; - c <<= ((128 - preflen) % 8); - *cp = c; + if (preflen % 8) + *cp = 0xff << (8 - preflen % 8); } } } |