From: Daniel Stenberg Date: Fri, 24 Feb 2023 11:39:26 +0000 (+0100) Subject: http_proxy: parse the status line without sscanf X-Git-Tag: curl-8_0_0~150 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3b8f5bb15b0b03862f479c8905e3bb068546b2f2;p=thirdparty%2Fcurl.git http_proxy: parse the status line without sscanf Closes #10602 --- diff --git a/lib/http_proxy.c b/lib/http_proxy.c index fdd092d034..9f214a305e 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -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; }