cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-2884561 ] CURLINFO_CONTENT_LENGTH_DOWNLOAD returning -1 for size = 0

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Sat, 31 Oct 2009 21:21:35 +0000

Bugs item #2884561, was opened at 2009-10-23 10:44
Message generated for change (Settings changed) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2884561&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
>Group: wrong behaviour
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Gabe (gkuri)
Assigned to: Daniel Stenberg (bagder)
Summary: CURLINFO_CONTENT_LENGTH_DOWNLOAD returning -1 for size = 0

Initial Comment:
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:

  case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
    *param_doublep = (data->progress.flags & PGRS_DL_SIZE_KNOWN)?
      (double)data->progress.size_dl:-1;
    break;

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;
  else
    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?

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2009-10-31 22:21

Message:
Thanks for the report, this problem is now fixed in CVS!

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2884561&group_id=976
Received on 2009-10-31

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET