Re: HTFTP: Support for resuming downloads with "REST" [patch]

"Tim Serong" <[email protected]>
Newsgroups gmane.comp.lib.libwww
Message-ID <[email protected]>
Hello Richard,

I found a small bug in the "REST" patch.  If I try to start at an offset
where the first digit is non-zero and every other digit is zero (ie:
100, 1000 etc.) it won't do the REST.  Here's the relevant code:

  s = rangeVal;
  if (*s < '0' || *s > '9') break;
  while (*++s >= '0' && *s <= '9') len += *s - '0';
  if (*s != '-' || s[1] != '\0' || len == 0) break;

The problem is, 's' is incremented before the first digit is added to
'len', so if all the remaining digits are zero, it'll just break out of
the loop.  This can be fixed by changing the 'while' line to the
following:

  while (*s >= '0' && *s <= '9') len += *s++ - '0';

Regards,

Tim Serong
-- 
[email protected]
http://www.conceiva.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.