cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_HEADERFUNCTION documentation and examples patches, now with actual patches!

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sat, 24 May 2008 08:29:41 -0700

On Sat, May 24, 2008 at 12:01:52PM +0400, Nikolai Kondrashov wrote:
> - retcode = read(fd, ptr, size * nmemb);
> + retcode = read(fd, ptr, size * nmemb) * size;

> - return fwrite(ptr, size, nmemb, stream);
> + return fwrite(ptr, size, nmemb, stream) * size;

Multiplying the return value by size like this just isn't right. The
callbacks are supposed to return the actual number of bytes read and written,
not some multiple of the number of bytes.

Suppose one day libcurl used a size of 2 for some reason, with nmemb of 5.
The callback would read or write 2*5=10 bytes in that case and it should
return a value of 10. Multiplying by size like is done above would return
a value of 20.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-05-24