Skip to content

Commit c17a4f0

Browse files
committed
axe an unnecessary call to sscanf() when parsing the response line
from the origin server apr_date_checkmask() already verified the expected text and digit positions; all that is needed is to cheaply find which digits git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@999694 13f79535-47bb-0310-9956-ffa450edef68
1 parent bf77898 commit c17a4f0

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

modules/proxy/mod_proxy_http.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,14 +1534,13 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
15341534
if (apr_date_checkmask(buffer, "HTTP/#.# ###*")) {
15351535
int major, minor;
15361536

1537-
if (2 != sscanf(buffer, "HTTP/%u.%u", &major, &minor)) {
1538-
major = 1;
1539-
minor = 1;
1540-
}
1537+
major = buffer[5] - '0';
1538+
minor = buffer[7] - '0';
1539+
15411540
/* If not an HTTP/1 message or
15421541
* if the status line was > 8192 bytes
15431542
*/
1544-
else if ((buffer[5] != '1') || (len >= sizeof(buffer)-1)) {
1543+
if ((major != 1) || (len >= sizeof(buffer)-1)) {
15451544
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
15461545
apr_pstrcat(p, "Corrupt status line returned by remote "
15471546
"server: ", buffer, NULL));

0 commit comments

Comments
 (0)