diff options
| author | David Cantrell <dcantrell@redhat.com> | 2008-06-27 03:25:34 -1000 |
|---|---|---|
| committer | David Cantrell <dcantrell@redhat.com> | 2008-06-27 03:25:38 -1000 |
| commit | 83389b2effe828debfbbcbebf87dbfd2cc12e361 (patch) | |
| tree | aeaffe2d818605590ffce1be6e894f861496fdd5 /loader2/net.c | |
| parent | adfa32b7ae12e10545c927f71655aaef950013a0 (diff) | |
Per strtol(3) man page, set errno=0 before call.
From the NOTES section of strtol(3):
"Since strtol() can legitimately return 0, LONG_MAX, or
LONG_MIN (LLONG_MAX or LLONG_MIN for strtoll()) on both
success and failure, the calling program should set errno
to 0 before the call, and then determine if an error
occurred by checking whether errno has a non-zero value
after the call."
Diffstat (limited to 'loader2/net.c')
| -rw-r--r-- | loader2/net.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/loader2/net.c b/loader2/net.c index 8e645525c..e191f990b 100644 --- a/loader2/net.c +++ b/loader2/net.c @@ -73,6 +73,7 @@ static void cidrCallback(newtComponent co, void * dptr) { if (inet_pton(AF_INET, data->cidr4, &addr) >= 1) return; + errno = 0; cidr = strtol(data->cidr4, NULL, 10); if ((errno == ERANGE && (cidr == LONG_MIN || cidr == LONG_MAX)) || (errno != 0 && cidr == 0)) { @@ -87,6 +88,7 @@ static void cidrCallback(newtComponent co, void * dptr) { if (data->cidr6 == NULL && data->ipv6 == NULL) return; + errno = 0; cidr = strtol(data->cidr6, NULL, 10); if ((errno == ERANGE && (cidr == LONG_MIN || cidr == LONG_MAX)) || (errno != 0 && cidr == 0)) { @@ -119,6 +121,7 @@ static void ipCallback(newtComponent co, void * dptr) { if (data->cidr4 == NULL && data->ipv4 != NULL) { buf = strdup(data->ipv4); octet = strtok(buf, "."); + errno = 0; i = strtol(octet, NULL, 10); if ((errno == ERANGE && (i == LONG_MIN || i == LONG_MAX)) || @@ -1163,6 +1166,7 @@ int manualNetConfig(char * device, struct networkDeviceConfig * cfg, newCfg->dev.set |= PUMP_INTFINFO_HAS_NETMASK; have[IPV4]++; } else { + errno = 0; cidr = strtol(ipcomps->cidr4, NULL, 10); if ((errno == ERANGE && (cidr == LONG_MIN || @@ -1196,6 +1200,7 @@ int manualNetConfig(char * device, struct networkDeviceConfig * cfg, } if (ipcomps->cidr6) { + errno = 0; prefix = strtol(ipcomps->cidr6, NULL, 10); if ((errno == ERANGE && (prefix == LONG_MIN || |
