aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-10-18 13:01:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-10-18 13:01:22 +0000
commit34cd7afc49778eb8f0f5c72d38fdbda13c03a1dc (patch)
tree30f3235307c2eefa01f308f69eeb9761a3d4fd98 /networking
parentf74194e942b7a65117914ecc9ddb62d9b1cc9e82 (diff)
downloadbusybox-34cd7afc49778eb8f0f5c72d38fdbda13c03a1dc.tar.gz
httpd: free big buffer after use; improve grep-ability of 'headers' variable
Diffstat (limited to 'networking')
-rw-r--r--networking/httpd.c33
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)
char http_major_version;
#if ENABLE_FEATURE_HTTPD_PROXY
char http_minor_version;
- char *headers = headers;
- char *headers_ptr = headers_ptr;
+ char *header_buf = header_buf; /* for gcc */
+ char *header_ptr = header_ptr;
Htaccess_Proxy *proxy_entry;
#endif
struct sigaction sa;
@@ -1916,7 +1916,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
#if ENABLE_FEATURE_HTTPD_PROXY
proxy_entry = find_proxy_entry(urlcopy);
if (proxy_entry)
- headers = headers_ptr = xmalloc(IOBUF_SIZE);
+ header_buf = header_ptr = xmalloc(IOBUF_SIZE);
#endif
if (http_major_version >= '0') {
@@ -1932,16 +1932,16 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
#if ENABLE_FEATURE_HTTPD_PROXY
/* We need 2 more bytes for yet another "\r\n" -
- * see fdprintf(proxy_fd...) further below */
- if (proxy_entry && headers_ptr - headers < IOBUF_SIZE - 2) {
+ * see near fdprintf(proxy_fd...) further below */
+ if (proxy_entry && (header_ptr - header_buf) < IOBUF_SIZE - 2) {
int len = strlen(iobuf);
- if (len > IOBUF_SIZE - (headers_ptr - headers) - 4)
- len = IOBUF_SIZE - (headers_ptr - headers) - 4;
- memcpy(headers_ptr, iobuf, len);
- headers_ptr += len;
- headers_ptr[0] = '\r';
- headers_ptr[1] = '\n';
- headers_ptr += 2;
+ if (len > IOBUF_SIZE - (header_ptr - header_buf) - 4)
+ len = IOBUF_SIZE - (header_ptr - header_buf) - 4;
+ memcpy(header_ptr, iobuf, len);
+ header_ptr += len;
+ header_ptr[0] = '\r';
+ header_ptr[1] = '\n';
+ header_ptr += 2;
}
#endif
@@ -2048,10 +2048,11 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
(g_query ? "?" : ""), /* "?" (maybe) */
(g_query ? g_query : ""), /* query string (maybe) */
http_major_version, http_minor_version);
- headers_ptr[0] = '\r';
- headers_ptr[1] = '\n';
- headers_ptr += 2;
- write(proxy_fd, headers, headers_ptr - headers);
+ header_ptr[0] = '\r';
+ header_ptr[1] = '\n';
+ header_ptr += 2;
+ write(proxy_fd, header_buf, header_ptr - header_buf);
+ free(header_buf); /* on the order of 8k, free it */
/* cgi_io_loop_and_exit needs to have two disctinct fds */
cgi_io_loop_and_exit(proxy_fd, dup(proxy_fd), length);
}