diff options
author | Eric Andersen | 2004-03-06 22:11:45 +0000 |
---|---|---|
committer | Eric Andersen | 2004-03-06 22:11:45 +0000 |
commit | 2479445562a9b5a9f226d0b00c41dbd533e63213 (patch) | |
tree | e4891420283c085d688683a41cc217dc896917b8 /networking | |
parent | c4db0833a6c91dd3714bec1db076a80910af6e30 (diff) | |
download | busybox-2479445562a9b5a9f226d0b00c41dbd533e63213.zip busybox-2479445562a9b5a9f226d0b00c41dbd533e63213.tar.gz |
Fix/eliminate use of atol
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ftpgetput.c | 5 | ||||
-rw-r--r-- | networking/ifconfig.c | 7 | ||||
-rw-r--r-- | networking/ipcalc.c | 3 | ||||
-rw-r--r-- | networking/route.c | 5 | ||||
-rw-r--r-- | networking/wget.c | 14 |
5 files changed, 22 insertions, 12 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 4f6be11..17ee8a5 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c @@ -147,7 +147,10 @@ static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream, fd_data = xconnect_ftpdata(server, buf); if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) { - filesize = atol(buf + 4); + unsigned long value=filesize; + if (safe_strtoul(buf + 4, &filesize)) + bb_error_msg_and_die("SIZE error: %s", buf + 4); + filesize = value; } if ((local_path[0] == '-') && (local_path[1] == '\0')) { diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 9fdab3c..341998d 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: ifconfig.c,v 1.27 2003/11/14 03:04:08 andersen Exp $ + * $Id: ifconfig.c,v 1.28 2004/03/06 22:11:44 andersen Exp $ * */ @@ -394,8 +394,9 @@ int ifconfig_main(int argc, char **argv) safe_strncpy(host, *argv, (sizeof host)); #ifdef CONFIG_FEATURE_IPV6 if ((prefix = strchr(host, '/'))) { - prefix_len = atol(prefix + 1); - if ((prefix_len < 0) || (prefix_len > 128)) { + if (safe_strtoi(prefix + 1, &prefix_len) || + (prefix_len < 0) || (prefix_len > 128)) + { ++goterr; goto LOOP; } diff --git a/networking/ipcalc.c b/networking/ipcalc.c index 2f1c02b..d75c883 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c @@ -119,8 +119,7 @@ int ipcalc_main(int argc, char **argv) if (*prefixstr) { unsigned int msk; - netprefix = atol(prefixstr); - if (netprefix > 32) { + if (safe_strtoul(prefixstr, &netprefix) || netprefix > 32) { IPCALC_MSG(bb_error_msg_and_die("bad IP prefix: %s\n", prefixstr), exit(EXIT_FAILURE)); } diff --git a/networking/route.c b/networking/route.c index 083149a..19942f4 100644 --- a/networking/route.c +++ b/networking/route.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: route.c,v 1.22 2003/03/19 09:12:39 mjn3 Exp $ + * $Id: route.c,v 1.23 2004/03/06 22:11:44 andersen Exp $ * * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> @@ -351,8 +351,7 @@ static int INET6_setroute(int action, int options, char **args) memset(&sa6, 0, sizeof(sa6)); } else { if ((cp = strchr(target, '/'))) { - prefix_len = atol(cp + 1); - if ((prefix_len < 0) || (prefix_len > 128)) + if (safe_strtod(cp + 1, &prefix_len) || (prefix_len < 0) || (prefix_len > 128)) bb_show_usage(); *cp = 0; } else { diff --git a/networking/wget.c b/networking/wget.c index 823a053..cb0790e 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -385,7 +385,11 @@ read_response: */ while ((s = gethdr(buf, sizeof(buf), sfp, &n)) != NULL) { if (strcasecmp(buf, "content-length") == 0) { - filesize = atol(s); + unsigned long value; + if (safe_strtoul(s, &value)) { + close_delete_and_die("content-length %s is garbage", s); + } + filesize = value; got_clen = 1; continue; } @@ -452,7 +456,11 @@ read_response: * Querying file size */ if (ftpcmd("SIZE /", target.path, sfp, buf) == 213) { - filesize = atol(buf+4); + unsigned long value; + if (safe_strtoul(buf+4, &value)) { + close_delete_and_die("SIZE value is garbage"); + } + filesize = value; got_clen = 1; } @@ -838,7 +846,7 @@ progressmeter(int flag) * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: wget.c,v 1.69 2004/02/22 00:27:34 bug1 Exp $ + * $Id: wget.c,v 1.70 2004/03/06 22:11:44 andersen Exp $ */ |