diff options
author | Daniel Stenberg <daniel@haxx.se> | 2007-01-13 23:33:21 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2007-01-13 23:33:21 +0000 |
commit | 869d65337ecc9e119a32a9b17b624e8a0c7d263c (patch) | |
tree | 0d79971319a33fe91bfcc5d3ec5e96f7b0c45ef8 | |
parent | 277df1c6b1dcb89ad3bfc63b2da48adb427865a1 (diff) |
fixed bad variable use when getting the size which we should read when
attempting not to read data that might belong to the next response (if
pipelining)
-rw-r--r-- | lib/transfer.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index 3004d14c3..ca112331e 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -347,8 +347,14 @@ CURLcode Curl_readwrite(struct connectdata *conn, 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 = 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); |