[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
PATCH [2/5]: mkinitrd: do not crash when netmask is specified (and even do the right thing)
- From: Hans de Goede <hdegoede redhat com>
- To: Discussion of Development and Customization of the Red Hat Linux Installer <anaconda-devel-list redhat com>
- Subject: PATCH [2/5]: mkinitrd: do not crash when netmask is specified (and even do the right thing)
- Date: Sun, 01 Feb 2009 15:11:37 +0100
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--;
}
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]