diff options
author | David Cantrell <dcantrell@redhat.com> | 2008-06-26 09:32:32 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2008-06-26 09:32:57 -1000 |
commit | 70b45f0621c98444dd5f1ce3eb5a77033d31c97d (patch) | |
tree | 80028ebb6b10d22715057ef47a8a7dfaefbbcd3a /loader2/urls.c | |
parent | 46161892b35ff5e87c0eabae2aa39e31bf9de4c0 (diff) | |
download | anaconda-70b45f0621c98444dd5f1ce3eb5a77033d31c97d.tar.gz anaconda-70b45f0621c98444dd5f1ce3eb5a77033d31c97d.tar.xz anaconda-70b45f0621c98444dd5f1ce3eb5a77033d31c97d.zip |
Use strtol() instead of atoi()
Code cleanup patch. Use strtol() to convert strings to
ints, rather than atoi(). No error checking capability
with atoi(). Also add error handling to detect strtol
failures.
Diffstat (limited to 'loader2/urls.c')
-rw-r--r-- | loader2/urls.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/loader2/urls.c b/loader2/urls.c index fae48a335..f95c75dcc 100644 --- a/loader2/urls.c +++ b/loader2/urls.c @@ -33,6 +33,7 @@ #include <string.h> #include <unistd.h> #include <netdb.h> +#include <errno.h> #include "ftp.h" #include "lang.h" @@ -176,10 +177,18 @@ int urlinstStartTransfer(struct iurlinfo * ui, char *path, ui->address, path); splitHostname(ui->address, &hostname, &portstr); - if (portstr == NULL) + if (portstr == NULL) { port = -1; - else - port = atoi(portstr); + } else { + port = strtol(portstr, NULL, 10); + + if ((errno == ERANGE && (port == LONG_MIN || port == LONG_MAX)) || + (errno != 0 && port == 0)) { + logMessage(ERROR, "%s: %d: %s", __func__, __LINE__, + strerror(errno)); + abort(); + } + } if (inet_pton(AF_INET, hostname, &addr) >= 1) family = AF_INET; |