cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: 7.16.0 regression with large files

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 12 Jan 2007 23:46:01 +0100 (CET)

On Thu, 11 Jan 2007, Toby Peterson wrote:

> It is related to the bytestoread value that's passed to Curl_read(). This
> small patch fixes the issue, though it's a very poor fix:

Update! I read the code again and now I think I realize what it was trying to
do and here's my updated take on patching away this problem:

diff -u -r1.327 transfer.c
--- lib/transfer.c 21 Dec 2006 10:18:15 -0000 1.327
+++ lib/transfer.c 12 Jan 2007 22:47:37 -0000
@@ -347,8 +347,14 @@
          size_t bytestoread = buffersize;
          int readrc;

- if (k->size != -1 && !k->header)
- bytestoread = (size_t)(k->size - k->bytecount);
+ if (k->size != -1 && !k->header) {
+ /* make sure we don't read "too much" if we can help it since we
+ might be pipelining and then someone else might want to read what
+ follows! */
+ curl_off_t totalleft = (size_t)(k->size - k->bytecount);
+ if(totalleft < bytestoread)
+ bytestoread = (size_t)totalleft;
+ }

          /* receive data from the network! */
          readrc = Curl_read(conn, conn->sockfd, k->buf, bytestoread, &nread);

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-01-12