]> sourceware.org Git - glibc.git/commitdiff
Handle zero prefix length in getifaddrs (BZ #17371)
authorAndreas Schwab <schwab@linux-m68k.org>
Sat, 13 Sep 2014 08:10:29 +0000 (10:10 +0200)
committerAndreas Schwab <schwab@linux-m68k.org>
Mon, 15 Sep 2014 16:59:37 +0000 (18:59 +0200)
ChangeLog
NEWS
sysdeps/unix/sysv/linux/ifaddrs.c

index e316f8c3b2e2efdeda9c2d72273be396423ab621..a40fb4622c6361fc85b84b0ce7e54aa7508c2407 100644 (file)
--- 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-15  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * sysdeps/posix/sysconf.c (__sysconf): Return -1 for
diff --git a/NEWS b/NEWS
index 680c265c68513cc643f7a6f695442387eddbcac4..231159071eeb71df3b8ec7328130b2fcf7a8aed6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@ Version 2.21
 
 * The following bugs are resolved with this release:
 
-  17363, 17370.
+  17363, 17370, 17371.
 \f
 Version 2.20
 
index 2c04e172ce32c8a39bac5cc08880a4d61157e6ce..a47b2edcad437b96c74952367dd7bb611b424b17 100644 (file)
@@ -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);
                    }
                }
            }
This page took 0.120445 seconds and 5 git commands to generate.