diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-11-29 16:22:35 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-12-01 16:18:36 +0100 |
commit | c50b878c15e029111787f6019b46581ecbc30c62 (patch) | |
tree | 18609b68020901e089b2792f37f5a5c899bf93ef /lib/http_proxy.c | |
parent | aab33215afb71c52404419bfa0783620a0b5cb75 (diff) |
CONNECT: reject TE or CL in 2xx responses
A server MUST NOT send any Transfer-Encoding or Content-Length header
fields in a 2xx (Successful) response to CONNECT. (RFC 7231 section
4.3.6)
Also fixes the three test cases that did this.
Diffstat (limited to 'lib/http_proxy.c')
-rw-r--r-- | lib/http_proxy.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/http_proxy.c b/lib/http_proxy.c index bbe2e8eb1..8ed9d08cb 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -529,6 +529,15 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, return result; } else if(checkprefix("Content-Length:", line_start)) { + if(k->httpcode/100 == 2) { + /* A server MUST NOT send any Transfer-Encoding or + Content-Length header fields in a 2xx (Successful) + response to CONNECT. (RFC 7231 section 4.3.6) */ + failf(data, "Content-Length: in %03d response", + k->httpcode); + return CURLE_RECV_ERROR; + } + cl = curlx_strtoofft(line_start + strlen("Content-Length:"), NULL, 10); } @@ -538,6 +547,14 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, else if(Curl_compareheader(line_start, "Transfer-Encoding:", "chunked")) { + if(k->httpcode/100 == 2) { + /* A server MUST NOT send any Transfer-Encoding or + Content-Length header fields in a 2xx (Successful) + response to CONNECT. (RFC 7231 section 4.3.6) */ + failf(data, "Transfer-Encoding: in %03d response", + k->httpcode); + return CURLE_RECV_ERROR; + } infof(data, "CONNECT responded chunked\n"); chunked_encoding = TRUE; /* init our chunky engine */ |