aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2014-09-13 10:10:29 +0200
committerAllan McRae <allan@archlinux.org>2014-09-16 09:04:16 +1000
commitea5509237291f1a109d46052353ece197f4213bc (patch)
tree3665fb2b4dbcbee9ebe7f7d5ca9c9b704135cd37
parent3b016908924afb5ef71ac874bedf8c6f0157941c (diff)
downloadtermbaud-ea5509237291f1a109d46052353ece197f4213bc.tar.gz
termbaud-ea5509237291f1a109d46052353ece197f4213bc.tar.xz
termbaud-ea5509237291f1a109d46052353ece197f4213bc.zip
Handle zero prefix length in getifaddrs (BZ #17371)
(cherry picked from commit a7b872687073decdcc7effc2289877d69058aca9) Conflicts: NEWS
-rw-r--r--ChangeLog6
-rw-r--r--NEWS6
-rw-r--r--sysdeps/unix/sysv/linux/ifaddrs.c11
3 files changed, 16 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index cc998186a1c..ed6b9aba16a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/NEWS b/NEWS
index 721b457a8b3..3373c96fe59 100644
--- a/NEWS
+++ b/NEWS
@@ -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 2c04e172ce3..a47b2edcad4 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);
}
}
}