[BusyBox] [Patch] wget: do not get stuck by trying to read too much
Junio C Hamano
junkio at cox.net
Fri Aug 29 00:09:37 UTC 2003
>>>>> "GM" == Glenn McGrath <bug1 at optushome.com.au> writes:
GM> Ive commited a fix for this to cvs, i simplified the logic.
I may be mistaken but aren't you breaking chunked case here?
The second argument to safe_fread in revision 1.54 and revision
1.55 (and the latest 1.56) are:
1.54
chunked
? (filesize > sizeof(buf) ? sizeof(buf) : filesize)
: sizeof(buf)
In human terms: if chunked then min(filesize, sizeof(buf))
otherwise always sizeof(buf)
1.55 & 1.56
(chunked || !got_clen || (filesize > sizeof(buf))
? sizeof(buf)
: filesize
In human terms: filesize is used only when (!chunked &&
got_clen && filesize <= sizeof(buf)); all others use
sizeof(buf).
What I sent you were this:
chunked
? (filesize > sizeof(buf)
? sizeof(buf) : filesize)
: (got_clen && filesize < sizeof(buf)
? filesize : sizeof(buf))
In human terms: if chunked, then keep using min(filesize,
sizeof(buf)) as before; otherwise if we know clen and
filesize < sizeof(buf) then use filesize; all else use
sizeof(buf)
Maybe you can re-rewrite as follows if you find it more
readable:
(chunked || got_clen) && (filesize < sizeof(buf))
? filesize
: sizeof(buf)
In human terms: if chunked or clen is known, then we can use
filesize to determine how much to read, so see if filesize is
smaller than sizeof(buf) and use filesize in that case. All
others keep using sizeof(buf) and have fread() time out.
More information about the busybox
mailing list