diff cli-runopts.c @ 492:b956d6151600

Replace calls to strtoul() with a helper m_str_to_uint()
author Matt Johnston <matt@ucc.asn.au>
date Mon, 22 Sep 2008 14:13:44 +0000
parents 79c657a673ec
children 6cd2152aae0b 66eac4631d88
line wrap: on
line diff
--- a/cli-runopts.c	Mon Sep 22 14:13:14 2008 +0000
+++ b/cli-runopts.c	Mon Sep 22 14:13:44 2008 +0000
@@ -355,8 +355,7 @@
 		}
 	}
 	if (keepalive_arg) {
-		opts.keepalive_secs = strtoul(keepalive_arg, NULL, 10);
-		if (opts.keepalive_secs == 0 && errno == EINVAL) {
+		if (m_str_to_uint(keepalive_arg, &opts.keepalive_secs) == DROPBEAR_FAILURE) {
 			dropbear_exit("Bad keepalive '%s'", keepalive_arg);
 		}
 	}
@@ -499,8 +498,7 @@
 		goto fail;
 	}
 	
-	cli_opts.netcat_port = strtoul(portstr, NULL, 10);
-	if (errno != 0) {
+	if (m_str_to_uint(portstr, &cli_opts.netcat_port) == DROPBEAR_FAILURE) {
 		TRACE(("bad netcat port"))
 		goto fail;
 	}
@@ -571,15 +569,13 @@
 
 	/* Now we check the ports - note that the port ints are unsigned,
 	 * the check later only checks for >= MAX_PORT */
-	newfwd->listenport = strtoul(listenport, NULL, 10);
-	if (errno != 0) {
-		TRACE(("bad listenport strtol"))
+	if (m_str_to_uint(listenport, &newfwd->listenport) == DROPBEAR_FAILURE) {
+		TRACE(("bad listenport strtoul"))
 		goto fail;
 	}
 
-	newfwd->connectport = strtoul(connectport, NULL, 10);
-	if (errno != 0) {
-		TRACE(("bad connectport strtol"))
+	if (m_str_to_uint(connectport, &newfwd->connectport) == DROPBEAR_FAILURE) {
+		TRACE(("bad connectport strtoul"))
 		goto fail;
 	}