summaryrefslogtreecommitdiffstats
path: root/isys/isys.c
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2008-06-26 09:32:32 -1000
committerDavid Cantrell <dcantrell@redhat.com>2008-06-26 09:32:57 -1000
commit70b45f0621c98444dd5f1ce3eb5a77033d31c97d (patch)
tree80028ebb6b10d22715057ef47a8a7dfaefbbcd3a /isys/isys.c
parent46161892b35ff5e87c0eabae2aa39e31bf9de4c0 (diff)
downloadanaconda-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 'isys/isys.c')
-rw-r--r--isys/isys.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/isys/isys.c b/isys/isys.c
index d1798d566..e2b40cb87 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -548,7 +548,13 @@ static PyObject * doConfigNetDevice(PyObject * s, PyObject * args) {
cfg.ipv6 = ip_addr_in6(&addr6);
if (strlen(prefix))
- i = atoi(prefix);
+ i = strtol(prefix, NULL, 10);
+
+ if ((errno == ERANGE && (i == LONG_MIN || i == LONG_MAX)) ||
+ (errno != 0 && i == 0)) {
+ return NULL;
+ }
+
if (i > 0 && i <= 128)
cfg.ipv6_prefixlen = i;
}