Date: Fri, 10 Jan 1997 21:48:30 -0800 (PST) From: hyama@acm.org To: freebsd-gnats-submit@freebsd.org Subject: bin/2443: Fetch cannot find the correct boundary between HTTP header and body. Message-ID: <199701110548.VAA00517@freefall.freebsd.org> Resent-Message-ID: <199701110550.VAA00641@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 2443 >Category: bin >Synopsis: Fetch cannot find the correct boundary between HTTP header and body. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jan 10 21:50:01 PST 1997 >Last-Modified: >Originator: Hideki Yamamoto >Organization: Oki Electric Industy Co., Ltd. >Release: FreeBSD 2.1.5 >Environment: FreeBSD imagen.pumpkin.kansai.oki.co.jp 2.1.5-RELEASE FreeBSD 2.1.5-RELEASE #2: Thu Jan 9 00:54:59 JST 1997 root@imagen.pumpkin.kansai.oki.co.jp:/usr/src/sys/compile/psm i386 >Description: fetch in FreeBSD-2.2-Beta (2.1.5 also) has a problem that it cannot fetch the following example correctly, because `filter' function in fetch handles the second `\r\n` as a boundary between the HTTP header and the body. I hope you will understand the problem and do something for 2.2-RELEASE. The following patch is an example to finds the first separator( `\r\n' or `\n\n' or `\r\r' ). Thank you for your efforts for FreeBSD. >How-To-Repeat: Type the following command: % fetch http://www.sun.com/index.html You can find the fetched `index.html' incomplete. >Fix: *** main.c.orig Thu Jan 9 01:33:22 1997 --- main.c Sat Jan 11 13:08:02 1997 *************** *** 644,649 **** --- 644,667 ---- return pmatch[1].rm_so ? pmatch[1].rm_so : -1; } + unsigned char * + min3(unsigned char *x, unsigned char *y, unsigned char *z) + { + if( (x)<=(y) ){ + if ((x)<=(z)){ + return (x); + }else{ + return (z); + } + }else{ + if ((y)<=(z)){ + return (y); + }else{ + return (z); + } + } + } + void filter (unsigned char *p, int len) { *************** *** 682,703 **** } } else { unsigned char *t; /* document begins with a success line. try to get size */ i = match ("content-length:[ \t]*([0-9]+)", s); if (i > 0) size = atoi (s+i); /* assume that the file to get begins after an empty line */ ! i = match ("(\n\n|\r\n\r\n)", s); ! if (i > 0) { ! if (s[i] == '\r') ! t = s+i+4; ! else ! t = s+i+2; ! } else { fprintf (stderr, "Can't decode the header!\n"); rm (); exit (1); } display (size, 0); n = (s-t)+header_len; i = fwrite (t, 1, n, file); --- 700,728 ---- } } else { unsigned char *t; + unsigned char *pp1,*pp2,*pp3,*pp,*ppmin,*plast; /* document begins with a success line. try to get size */ i = match ("content-length:[ \t]*([0-9]+)", s); if (i > 0) size = atoi (s+i); /* assume that the file to get begins after an empty line */ ! plast = &s[S]; ! pp1 = ( ( pp = strstr (s,"\r\n\r\n")) !=NULL )? pp : plast; ! pp2 = ( ( pp = strstr (s,"\n\n")) !=NULL )? pp : plast; ! pp3 = ( ( pp = strstr (s,"\r\r")) !=NULL )? pp : plast; ! ppmin = min3( pp1, pp2, pp3 ); ! ! if( ppmin == plast ) { fprintf (stderr, "Can't decode the header!\n"); rm (); exit (1); } + if( pp1 == ppmin ) + t = pp1+4; + else if( pp2 == ppmin ) + t = pp2+2; + else + t = pp3+2; display (size, 0); n = (s-t)+header_len; i = fwrite (t, 1, n, file); >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701110548.VAA00517>