[BusyBox-cvs] busybox/networking ftpgetput.c, 1.14, 1.15 ifconfig.c, 1.27, 1.28 ipcalc.c, 1.7, 1.8 route.c, 1.22, 1.23 wget.c, 1.69, 1.70
Erik Andersen
andersen at busybox.net
Sat Mar 6 22:11:47 UTC 2004
Update of /var/cvs/busybox/networking
In directory nail:/tmp/cvs-serv7369/networking
Modified Files:
ftpgetput.c ifconfig.c ipcalc.c route.c wget.c
Log Message:
Fix/eliminate use of atol
Index: ifconfig.c
===================================================================
RCS file: /var/cvs/busybox/networking/ifconfig.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- a/ifconfig.c 14 Nov 2003 03:04:08 -0000 1.27
+++ b/ifconfig.c 6 Mar 2004 22:11:44 -0000 1.28
@@ -394,8 +394,9 @@
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;
}
Index: ipcalc.c
===================================================================
RCS file: /var/cvs/busybox/networking/ipcalc.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- a/ipcalc.c 12 Sep 2003 00:44:50 -0000 1.7
+++ b/ipcalc.c 6 Mar 2004 22:11:44 -0000 1.8
@@ -119,8 +119,7 @@
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));
}
Index: ftpgetput.c
===================================================================
RCS file: /var/cvs/busybox/networking/ftpgetput.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- a/ftpgetput.c 17 Jan 2004 05:03:31 -0000 1.14
+++ b/ftpgetput.c 6 Mar 2004 22:11:44 -0000 1.15
@@ -147,7 +147,10 @@
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')) {
Index: route.c
===================================================================
RCS file: /var/cvs/busybox/networking/route.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- a/route.c 19 Mar 2003 09:12:39 -0000 1.22
+++ b/route.c 6 Mar 2004 22:11:44 -0000 1.23
@@ -351,8 +351,7 @@
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 {
Index: wget.c
===================================================================
RCS file: /var/cvs/busybox/networking/wget.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- a/wget.c 22 Feb 2004 00:27:34 -0000 1.69
+++ b/wget.c 6 Mar 2004 22:11:44 -0000 1.70
@@ -385,7 +385,11 @@
*/
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 @@
* 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;
}
More information about the busybox-cvs
mailing list