aboutsummaryrefslogtreecommitdiff
path: root/lib/http_proxy.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-11-30 00:09:13 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-12-01 16:18:36 +0100
commit3ea3518429c00c422d0b706be13b131b6a443a17 (patch)
tree32e0fce6e9480a615e5ab363b494b1ce62d111fa /lib/http_proxy.c
parentc50b878c15e029111787f6019b46581ecbc30c62 (diff)
CONNECT: read responses one byte at a time
... so that it doesn't read data that is actually coming from the remote. 2xx responses have no body from the proxy, that data is from the peer. Fixes #1132
Diffstat (limited to 'lib/http_proxy.c')
-rw-r--r--lib/http_proxy.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 8ed9d08cb..c890c85af 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -328,9 +328,11 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
case 0: /* timeout */
break;
default:
- DEBUGASSERT(ptr+BUFSIZE-nread <= data->state.buffer+BUFSIZE+1);
- result = Curl_read(conn, tunnelsocket, ptr, BUFSIZE-nread,
- &gotbytes);
+ if(ptr >= &data->state.buffer[BUFSIZE]) {
+ failf(data, "CONNECT response too large!");
+ return CURLE_RECV_ERROR;
+ }
+ result = Curl_read(conn, tunnelsocket, ptr, 1, &gotbytes);
if(result==CURLE_AGAIN)
continue; /* go loop yourself */
else if(result)
@@ -445,15 +447,6 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
if(cl) {
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
" bytes of response-body\n", cl);
-
- /* remove the remaining chunk of what we already
- read */
- cl -= (gotbytes - i);
-
- if(cl<=0)
- /* if the whole thing was already read, we are done!
- */
- keepon=FALSE;
}
else if(chunked_encoding) {
CHUNKcode r;
@@ -473,8 +466,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
/* now parse the chunked piece of data so that we can
properly tell when the stream ends */
- r = Curl_httpchunk_read(conn, line_start+1,
- gotbytes -i, &gotbytes);
+ r = Curl_httpchunk_read(conn, line_start+1, 1,
+ &gotbytes);
if(r == CHUNKE_STOP) {
/* we're done reading chunks! */
infof(data, "chunk reading DONE\n");