cURL / Mailing Lists / curl-library / Single Mail



From: Gabriel Kuri <>
Date: Wed, 21 Oct 2009 15:18:14 -0700

I am using the Linux FUSE driver to access the Amazon S3 storage cloud,
and ran into a problem recently when upgrading to curl 7.19 that I
believe is a bug in curl. Basically, files whose size should be zero
were instead showing up with size MAXINT. I traced this down to a
change in lib/getinfo.c:

    *param_doublep = (data->progress.flags & PGRS_DL_SIZE_KNOWN)?

Previously, this code simply returned data->progress.size_dl. Now, if
the PGRS_DL_SIZE_KNOWN bit is not set, it returns -1 instead. As the
FUSE driver driver casts the returned value into an unsigned variable,
the result ends up becoming MAXINT.

The PGRS_DL_SIZE_KNOWN bit is set by the following code in lib/progress.c:

void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size)
  data->progress.size_dl = size;
  if(size > 0)
    data->progress.flags |= PGRS_DL_SIZE_KNOWN;
    data->progress.flags &= ~PGRS_DL_SIZE_KNOWN;

However, I believe a Content-Length of 0 is valid, not unknown -- this
code would appear to be considering the size as unknown if the size is
not greater than zero. This appears to result in the inability to
distinguish the difference between an unknown size and a size that is
truly 0 (ironically, the description of the bug the change to
lib/getinfo.c was intended to resolve ;) )

Based on the following comment in lib/urldata.h:

struct SingleRequest {
  curl_off_t size; /* -1 if unknown at this point */

Should the check in Curl_pgrsSetDownloadSize be for >=0 rather than >0?
If not, what would be a better way to allow the API to distinguish
between content-length unknown and content-length of zero?

Gabriel Kuri | Sr. Network Engineer
Instructional and Information Technology Division
California State Polytechnic University, Pomona | +1 909 979 6363

List admin:
Received on 2009-10-22