diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-18 13:01:22 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-18 13:01:22 +0000 |
commit | 34cd7afc49778eb8f0f5c72d38fdbda13c03a1dc (patch) | |
tree | 30f3235307c2eefa01f308f69eeb9761a3d4fd98 | |
parent | f74194e942b7a65117914ecc9ddb62d9b1cc9e82 (diff) | |
download | busybox-w32-34cd7afc49778eb8f0f5c72d38fdbda13c03a1dc.tar.gz busybox-w32-34cd7afc49778eb8f0f5c72d38fdbda13c03a1dc.tar.bz2 busybox-w32-34cd7afc49778eb8f0f5c72d38fdbda13c03a1dc.zip |
httpd: free big buffer after use; improve grep-ability of 'headers' variable
-rw-r--r-- | networking/httpd.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index af1f61d2d..e4922e509 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -1759,8 +1759,8 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
1759 | char http_major_version; | 1759 | char http_major_version; |
1760 | #if ENABLE_FEATURE_HTTPD_PROXY | 1760 | #if ENABLE_FEATURE_HTTPD_PROXY |
1761 | char http_minor_version; | 1761 | char http_minor_version; |
1762 | char *headers = headers; | 1762 | char *header_buf = header_buf; /* for gcc */ |
1763 | char *headers_ptr = headers_ptr; | 1763 | char *header_ptr = header_ptr; |
1764 | Htaccess_Proxy *proxy_entry; | 1764 | Htaccess_Proxy *proxy_entry; |
1765 | #endif | 1765 | #endif |
1766 | struct sigaction sa; | 1766 | struct sigaction sa; |
@@ -1916,7 +1916,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
1916 | #if ENABLE_FEATURE_HTTPD_PROXY | 1916 | #if ENABLE_FEATURE_HTTPD_PROXY |
1917 | proxy_entry = find_proxy_entry(urlcopy); | 1917 | proxy_entry = find_proxy_entry(urlcopy); |
1918 | if (proxy_entry) | 1918 | if (proxy_entry) |
1919 | headers = headers_ptr = xmalloc(IOBUF_SIZE); | 1919 | header_buf = header_ptr = xmalloc(IOBUF_SIZE); |
1920 | #endif | 1920 | #endif |
1921 | 1921 | ||
1922 | if (http_major_version >= '0') { | 1922 | if (http_major_version >= '0') { |
@@ -1932,16 +1932,16 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
1932 | 1932 | ||
1933 | #if ENABLE_FEATURE_HTTPD_PROXY | 1933 | #if ENABLE_FEATURE_HTTPD_PROXY |
1934 | /* We need 2 more bytes for yet another "\r\n" - | 1934 | /* We need 2 more bytes for yet another "\r\n" - |
1935 | * see fdprintf(proxy_fd...) further below */ | 1935 | * see near fdprintf(proxy_fd...) further below */ |
1936 | if (proxy_entry && headers_ptr - headers < IOBUF_SIZE - 2) { | 1936 | if (proxy_entry && (header_ptr - header_buf) < IOBUF_SIZE - 2) { |
1937 | int len = strlen(iobuf); | 1937 | int len = strlen(iobuf); |
1938 | if (len > IOBUF_SIZE - (headers_ptr - headers) - 4) | 1938 | if (len > IOBUF_SIZE - (header_ptr - header_buf) - 4) |
1939 | len = IOBUF_SIZE - (headers_ptr - headers) - 4; | 1939 | len = IOBUF_SIZE - (header_ptr - header_buf) - 4; |
1940 | memcpy(headers_ptr, iobuf, len); | 1940 | memcpy(header_ptr, iobuf, len); |
1941 | headers_ptr += len; | 1941 | header_ptr += len; |
1942 | headers_ptr[0] = '\r'; | 1942 | header_ptr[0] = '\r'; |
1943 | headers_ptr[1] = '\n'; | 1943 | header_ptr[1] = '\n'; |
1944 | headers_ptr += 2; | 1944 | header_ptr += 2; |
1945 | } | 1945 | } |
1946 | #endif | 1946 | #endif |
1947 | 1947 | ||
@@ -2048,10 +2048,11 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2048 | (g_query ? "?" : ""), /* "?" (maybe) */ | 2048 | (g_query ? "?" : ""), /* "?" (maybe) */ |
2049 | (g_query ? g_query : ""), /* query string (maybe) */ | 2049 | (g_query ? g_query : ""), /* query string (maybe) */ |
2050 | http_major_version, http_minor_version); | 2050 | http_major_version, http_minor_version); |
2051 | headers_ptr[0] = '\r'; | 2051 | header_ptr[0] = '\r'; |
2052 | headers_ptr[1] = '\n'; | 2052 | header_ptr[1] = '\n'; |
2053 | headers_ptr += 2; | 2053 | header_ptr += 2; |
2054 | write(proxy_fd, headers, headers_ptr - headers); | 2054 | write(proxy_fd, header_buf, header_ptr - header_buf); |
2055 | free(header_buf); /* on the order of 8k, free it */ | ||
2055 | /* cgi_io_loop_and_exit needs to have two disctinct fds */ | 2056 | /* cgi_io_loop_and_exit needs to have two disctinct fds */ |
2056 | cgi_io_loop_and_exit(proxy_fd, dup(proxy_fd), length); | 2057 | cgi_io_loop_and_exit(proxy_fd, dup(proxy_fd), length); |
2057 | } | 2058 | } |