[BusyBox] ftpget fails on SIZE command

Sauder, Vernon Vernon.Sauder at spirentcom.com
Tue May 4 00:05:41 UTC 2004


The SIZE command seems to be failing on FTPGET. I traced it to the use of
safe_strtoul where the endptr is checked against valid values. Since the
buffer passed is the response to the SIZE command, it will probably contain
a new line character. I search for a carriage-return and terminate the
buffer there. I noticed that some other commands have this problem too so
maybe a more generic change is in order. Anyway, here is the quick fix.

diff -ur busybox.orig/networking/ftpgetput.c
busybox.new/networking/ftpgetput.c
--- busybox.orig/networking/ftpgetput.c	2004-04-25 01:11:17.000000000 -0400
+++ busybox.new/networking/ftpgetput.c	2004-05-03 20:00:45.000000000 -0400
@@ -148,6 +148,9 @@
 
 	if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) {
 		unsigned long value=filesize;
+		char *p;
+		if ((p = strchr(buf, '\r')))
+			*p = '\0';
 		if (safe_strtoul(buf + 4, &value))
 			bb_error_msg_and_die("SIZE error: %s", buf + 4);
 		filesize = value;


Regards,
Vern



More information about the busybox mailing list