http_proxy: parse the status line without sscanf

Closes #10602
This commit is contained in:
Daniel Stenberg 2023-02-24 12:39:26 +01:00
parent cbd3fd7cbb
commit 3b8f5bb15b
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -403,7 +403,6 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf,
{
CURLcode result = CURLE_OK;
struct SingleRequest *k = &data->req;
int subversion = 0;
(void)cf;
if((checkprefix("WWW-Authenticate:", header) &&
@ -461,11 +460,14 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf,
STRCONST("Proxy-Connection:"),
STRCONST("close")))
ts->close_connection = TRUE;
else if(2 == sscanf(header, "HTTP/1.%d %d",
&subversion,
&k->httpcode)) {
else if(!strncmp(header, "HTTP/1.", 7) &&
((header[7] == '0') || (header[7] == '1')) &&
(header[8] == ' ') &&
ISDIGIT(header[9]) && ISDIGIT(header[10]) && ISDIGIT(header[11]) &&
!ISDIGIT(header[12])) {
/* store the HTTP code from the proxy */
data->info.httpproxycode = k->httpcode;
data->info.httpproxycode = k->httpcode = (header[9] - '0') * 100 +
(header[10] - '0') * 10 + (header[11] - '0');
}
return result;
}