summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-05-18 00:35:31 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-05-18 00:35:31 +0000
commit8df3626ae183a2febde90a749c12ae1f425b9ffc (patch)
tree9e078b84bc590f1c9228f80aa03e52ee256c4bde /mdk-stage1
parent2b6f7b53352babe10abc8d2bfdccb4f7e8fbe33e (diff)
downloaddrakx-backup-do-not-use-8df3626ae183a2febde90a749c12ae1f425b9ffc.tar
drakx-backup-do-not-use-8df3626ae183a2febde90a749c12ae1f425b9ffc.tar.gz
drakx-backup-do-not-use-8df3626ae183a2febde90a749c12ae1f425b9ffc.tar.bz2
drakx-backup-do-not-use-8df3626ae183a2febde90a749c12ae1f425b9ffc.tar.xz
drakx-backup-do-not-use-8df3626ae183a2febde90a749c12ae1f425b9ffc.zip
- better detect when IP is not good
- error_msg when netmask seems invalid - don't log too much `guessing netmask'
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/network.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index 7e154de2a..4efecda13 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -311,11 +311,11 @@ char * guess_netmask(char * ip_addr)
struct in_addr addr;
unsigned long int tmp;
- log_message("guessing netmask");
-
if (streq(ip_addr, "") || !inet_aton(ip_addr, &addr))
return "";
+ log_message("guessing netmask");
+
tmp = ntohl(addr.s_addr);
if (((tmp & 0xFF000000) >> 24) <= 127)
@@ -372,7 +372,7 @@ static enum return_type setup_network_interface(struct interface_info * intf)
if (results != RETURN_OK)
return setup_network_interface(intf);
- if (!inet_aton(answers[0], &addr)) {
+ if (streq(answers[0], "") || !inet_aton(answers[0], &addr)) {
stg1_error_message("Invalid IP address.");
return setup_network_interface(intf);
}
@@ -391,6 +391,10 @@ static enum return_type setup_network_interface(struct interface_info * intf)
if ((streq(answers[3], "") && inet_aton(guess_netmask(answers[0]), &addr))
|| inet_aton(answers[3], &addr))
memcpy(&intf->netmask, &addr, sizeof(addr));
+ else {
+ stg1_error_message("Invalid netmask.");
+ return setup_network_interface(intf);
+ }
*((uint32_t *) &intf->broadcast) = (*((uint32_t *) &intf->ip) &
*((uint32_t *) &intf->netmask)) | ~(*((uint32_t *) &intf->netmask));