Httpd fails to honor byte range requests if the range begins with 0. Whether to return a byte range is predicated on the value of range_start (treated as a boolean). If range start is 0, httpd treats the request as if it were for the entire file. Range: bytes=0-1 of a 100 byte file returns 100 bytes.
Created attachment 4046 [details] change byte range test to use a separate boolean
I don't know how sensitive BusyBox is to a word vs. a byte vs. a bit for data. Negative values of range_start could also be used as a positive boolean, instead of the smallint range_req I've proposed. To summarize: if a range is requested and the Range: header is reasonable, set range_start to requested value | ~MAX_INT (sets high bit) range_start == 0 => no byte range requested or served range_start != 0 => serve a byte range starting from (range_start ^ ~MAX_INT) I don't know if BusyBox httpd has been tested or is expected to work with > 2GB files, though.
(In reply to comment #2) > I don't know how sensitive BusyBox is to a word vs. a byte vs. a bit for data. You can check the size increase with $ scripts/bloat-o-meter busybox_unstripped.unpatched busybox_unstripped (cp busybox_unstripped busybox_unstripped.unpatched for a pristine build, then apply your patch and rebuild). > Negative values of range_start could also be used as a positive boolean, > instead of the smallint range_req I've proposed. > > To summarize: > if a range is requested and the Range: header is reasonable, set range_start to > requested value | ~MAX_INT (sets high bit) > > range_start == 0 => no byte range requested or served > range_start != 0 => serve a byte range starting from (range_start ^ ~MAX_INT) > > I don't know if BusyBox httpd has been tested or is expected to work with > 2GB > files, though. The httpd works fine with files > 2GB, yes.
I propose to change "range_start != 0" condition for range_start >= 0 everywhere, and set range_start = -1 when range is off.
Fixed in git: http://git.busybox.net/busybox/commit/?id=8cce1b3ad8c28b5c34c24d79b32b6cebb75ea2f5