Fix ftp resume

Terminate returned message at <CRLF> so strtoul returns without error
This commit is contained in:
Glenn L McGrath 2004-04-08 10:27:11 +00:00
parent 66a56aa028
commit 32da885a91

View File

@ -660,8 +660,6 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf)
{ {
char *p;
if (s1) { if (s1) {
if (!s2) s2=""; if (!s2) s2="";
fprintf(fp, "%s%s\r\n", s1, s2); fprintf(fp, "%s%s\r\n", s1, s2);
@ -669,9 +667,15 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf)
} }
do { do {
p = fgets(buf, 510, fp); char *buf_ptr;
if (!p)
if (fgets(buf, 510, fp) == NULL) {
bb_perror_msg_and_die("fgets()"); bb_perror_msg_and_die("fgets()");
}
buf_ptr = strstr(buf, "\r\n");
if (buf_ptr) {
*buf_ptr = '\0';
}
} while (! isdigit(buf[0]) || buf[3] != ' '); } while (! isdigit(buf[0]) || buf[3] != ' ');
return atoi(buf); return atoi(buf);
@ -846,7 +850,7 @@ progressmeter(int flag)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: wget.c,v 1.72 2004/03/27 10:02:43 andersen Exp $ * $Id: wget.c,v 1.73 2004/04/08 10:27:11 bug1 Exp $
*/ */