HTTP: return larger than 3 digit response codes too

HTTP 1.1 is clearly specified to only allow three digit response codes,
and libcurl used sscanf("%3d") for that purpose. This made libcurl
support smaller numbers but not larger. It does now, but we will not
make any specific promises nor document this further since it is going
outside of what HTTP is.

Bug: http://curl.haxx.se/bug/view.cgi?id=1441
Reported-by: Balaji
This commit is contained in:
Daniel Stenberg
2014-10-27 16:08:24 +01:00
parent ad88a4bbba
commit 95765567d0
7 changed files with 307 additions and 2 deletions

View File

@@ -3200,8 +3200,15 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
#endif /* CURL_DOES_CONVERSIONS */
if(conn->handler->protocol & PROTO_FAMILY_HTTP) {
/*
* https://tools.ietf.org/html/rfc7230#section-3.1.2
*
* The reponse code is always a three-digit number in HTTP as the spec
* says. We try to allow any number here, but we cannot make
* guarantees on future behaviors since it isn't within the protocol.
*/
nc = sscanf(HEADER1,
" HTTP/%d.%d %3d",
" HTTP/%d.%d %d",
&httpversion_major,
&conn->httpversion,
&k->httpcode);