PATCH [2/5]: mkinitrd: do not crash when netmask is specified (and even do the right thing)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

The current mkinitrd netmask handling codes, crashes, and even with that fixed, only works in little endian systems, and then only when the prefix is a multiple of 8, and then still has an of by one error <sigh>

This patch fixes all of the above.

Regards,

Hans

diff -up mkinitrd-6.0.75/nash/network.c.bar mkinitrd-6.0.75/nash/network.c
--- mkinitrd-6.0.75/nash/network.c.bar	2009-01-30 17:50:21.000000000 +0100
+++ mkinitrd-6.0.75/nash/network.c	2009-01-30 21:08:18.000000000 +0100
@@ -282,10 +292,12 @@ static char *nashSetupInterface(char *de
     }
 
     if (netmask != NULL) {
-        if (inet_pton(AF_INET, netmask, &addr) > 0) {
-            while (mask.s_addr != 0) {
-                mask.s_addr = mask.s_addr >> 1;
-                prefix++;
+        if (inet_pton(AF_INET, netmask, &mask) > 0) {
+            unsigned int s_addr = ntohl(mask.s_addr);
+            prefix = 32;
+            while (!(s_addr & 1)) {
+                s_addr >>= 1;
+                prefix--;
             }
         }
 
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux