]> granicus.if.org Git - apache/commitdiff
axe an unnecessary call to sscanf() when parsing the response line
authorJeff Trawick <trawick@apache.org>
Wed, 22 Sep 2010 00:07:52 +0000 (00:07 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 22 Sep 2010 00:07:52 +0000 (00:07 +0000)
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

modules/proxy/mod_proxy_http.c

index d1de99a3f7686cdd12b80df995cf7376cc4e4b62..4cb598ebe21e84b942ede5ef17cc834af5520350 100644 (file)
@@ -1534,14 +1534,13 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
         if (apr_date_checkmask(buffer, "HTTP/#.# ###*")) {
             int major, minor;
 
-            if (2 != sscanf(buffer, "HTTP/%u.%u", &major, &minor)) {
-                major = 1;
-                minor = 1;
-            }
+            major = buffer[5] - '0';
+            minor = buffer[7] - '0';
+
             /* If not an HTTP/1 message or
              * if the status line was > 8192 bytes
              */
-            else if ((buffer[5] != '1') || (len >= sizeof(buffer)-1)) {
+            if ((major != 1) || (len >= sizeof(buffer)-1)) {
                 return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                 apr_pstrcat(p, "Corrupt status line returned by remote "
                             "server: ", buffer, NULL));