Re: some linux tuning

From: Stephen R. van den Berg <srb@dont-contact.us>
Date: Tue, 29 Jun 1999 12:06:11 +0200

Jeff Barrow wrote:
>Could you look at something for me:
>In client_side.c around line 1900...

>There seem to be 3 cases where inbuf is allocated but not freed (error
>cases)... is this correct? With transparent proxies, this could be what's

Even more so, apparently.
It looked serious enough to patch myself, in case you didn't yet, try this:

diff -U 2 -b -B -p -r -d --horizon-lines=2 -X /usr/local/etc/xdiff squid-2.2.STABLE3/src/client_side.c squid-B2/src/client_side.c
--- squid-2.2.STABLE3/src/client_side.c Mon May 10 18:00:40 1999
+++ squid-B2/src/client_side.c Tue Jun 29 11:39:33 1999
@@ -1948,15 +1998,18 @@ parseHttpRequest(ConnStateData * conn, m
     if (strlen(inbuf) != req_sz) {
         debug(33, 1) ("parseHttpRequest: Requestheader contains NULL characters\n");
- return parseHttpRequestAbort(conn, "error:invalid-request");
+ http = parseHttpRequestAbort(conn, "error:invalid-request");
+ goto ret;
     }
     /* Look for request method */
     if ((mstr = strtok(inbuf, "\t ")) == NULL) {
         debug(33, 1) ("parseHttpRequest: Can't get request method\n");
- return parseHttpRequestAbort(conn, "error:invalid-request-method");
+ http = parseHttpRequestAbort(conn, "error:invalid-request-method");
+ goto ret;
     }
     method = urlParseMethod(mstr);
     if (method == METHOD_NONE) {
         debug(33, 1) ("parseHttpRequest: Unsupported method '%s'\n", mstr);
- return parseHttpRequestAbort(conn, "error:unsupported-request-method");
+ http = parseHttpRequestAbort(conn, "error:unsupported-request-method");
+ goto ret;
     }
     debug(33, 5) ("parseHttpRequest: Method is '%s'\n", mstr);
@@ -1966,5 +2019,6 @@ parseHttpRequest(ConnStateData * conn, m
     if ((url = strtok(NULL, "\n")) == NULL) {
         debug(33, 1) ("parseHttpRequest: Missing URL\n");
- return parseHttpRequestAbort(conn, "error:missing-url");
+ http = parseHttpRequestAbort(conn, "error:missing-url");
+ goto ret;
     }
     while (xisspace(*url))
@@ -1988,5 +2042,6 @@ parseHttpRequest(ConnStateData * conn, m
         http_ver = (float) 0.9; /* wild guess */
 #else
- return parseHttpRequestAbort(conn, "error:missing-http-ident");
+ http = parseHttpRequestAbort(conn, "error:missing-http-ident");
+ goto ret;
 #endif
     } else {
@@ -2002,5 +2057,6 @@ parseHttpRequest(ConnStateData * conn, m
         debug(33, 3) ("parseHttpRequest: header_sz == 0\n");
         *status = 0;
- return NULL;
+ http = NULL;
+ goto ret;
     }
     assert(header_sz > 0);
@@ -2073,5 +2129,6 @@ parseHttpRequest(ConnStateData * conn, m
                 debug(50, 1) ("parseHttpRequest: NAT open failed: %s\n",
                     xstrerror());
- return parseHttpRequestAbort(conn, "error:nat-open-failed");
+ http = parseHttpRequestAbort(conn, "error:nat-open-failed");
+ goto ret;
             }
             if (ioctl(natfd, SIOCGNATL, &natLookup) < 0) {
@@ -2080,5 +2137,6 @@ parseHttpRequest(ConnStateData * conn, m
                     close(natfd);
                     natfd = -1;
- return parseHttpRequestAbort(conn, "error:nat-lookup-failed");
+ http = parseHttpRequestAbort(conn, "error:nat-lookup-failed");
+ goto ret;
                 } else
                     snprintf(http->uri, url_sz, "http://%s:%d%s",
@@ -2119,6 +2177,7 @@ parseHttpRequest(ConnStateData * conn, m
     if (free_request)
         safe_free(url);
- xfree(inbuf);
     *status = 1;
+ret:
+ xfree(inbuf);
     return http;
 }

-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg (AKA BuGless).
Real programmers don't just die, they produce core dumps.
Received on Tue Jun 29 1999 - 04:15:12 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:47:02 MST