Re: ftp, ignore whitespace at end of Content-Length

2012-05-28 Thread LEVAI Daniel
> As noted on misc, ftp http://www.spamhaus.org/drop/drop.lasso fails due
> to whitespace after the value of the content-length header.
> 
> wget/curl/lynx/w3m all handle this.

This is really useful, thanks!


Daniel

-- 
LIVAI Daniel
PGP key ID = 0x83B63A8F
Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F



ftp, ignore whitespace at end of Content-Length

2012-04-23 Thread Stuart Henderson
As noted on misc, ftp http://www.spamhaus.org/drop/drop.lasso fails due
to whitespace after the value of the content-length header.

wget/curl/lynx/w3m all handle this.

OK?

Index: fetch.c
===
RCS file: /cvs/src/usr.bin/ftp/fetch.c,v
retrieving revision 1.103
diff -u -p -r1.103 fetch.c
--- fetch.c 25 Aug 2010 20:32:37 -  1.103
+++ fetch.c 23 Apr 2012 07:19:45 -
@@ -746,7 +746,10 @@ again:
cp = buf;
 #define CONTENTLEN "Content-Length: "
if (strncasecmp(cp, CONTENTLEN, sizeof(CONTENTLEN) - 1) == 0) {
+   size_t s;
cp += sizeof(CONTENTLEN) - 1;
+   if (s=strcspn(cp, " \t"))
+   *(cp+s) = 0;
filesize = strtonum(cp, 0, LLONG_MAX, &errstr);
if (errstr != NULL)
goto improper;