about summary refs log tree commit diff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/ifaddrs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index d83e8f8e84..6deb09445b 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -780,10 +780,10 @@ getifaddrs_internal (struct ifaddrs **ifap)
 		      else
 			preflen = ifam->ifa_prefixlen;
 
-		      for (i = 0; i < (preflen / 8); i++)
+		      for (i = 0; i < ((preflen - 1) / 8); i++)
 			*cp++ = 0xff;
 		      c = 0xff;
-		      c <<= (8 - (preflen % 8));
+		      c <<= ((128 - preflen) % 8);
 		      *cp = c;
 		    }
 		}