diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2014-09-13 10:10:29 +0200 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2014-09-15 18:59:37 +0200 |
commit | a7b872687073decdcc7effc2289877d69058aca9 (patch) | |
tree | 45e2241ca8b82dcae52420f821c4889fdd69e62c /sysdeps/unix/sysv/linux | |
parent | 61fe374a44a92621e0b75ec1f011ff1fba6c2148 (diff) | |
download | glibc-a7b872687073decdcc7effc2289877d69058aca9.tar.gz glibc-a7b872687073decdcc7effc2289877d69058aca9.tar.xz glibc-a7b872687073decdcc7effc2289877d69058aca9.zip |
Handle zero prefix length in getifaddrs (BZ #17371)
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r-- | sysdeps/unix/sysv/linux/ifaddrs.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index 2c04e172ce..a47b2edcad 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); } } } |