W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2003

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

From: Tim Serong <tim.serong@conceiva.com>
Date: Fri, 14 Mar 2003 12:12:38 +1100
Message-ID: <8501919721C3DE4C81BCA22846B08721BC11@lazarus.conceiva.com>
To: <richard@list03.atterer.net>
Cc: <www-lib@w3.org>

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
-- 
tim.serong@conceiva.com
http://www.conceiva.com
Received on Thursday, 13 March 2003 20:12:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:43 GMT