diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-14 20:46:57 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-14 20:46:57 +0200 |
commit | 02d650e15919e48fe031308c77c041159c0e3631 (patch) | |
tree | 05da096c443553dd7845955901240cc1a7794f8e | |
parent | 51792e126bddaabf572132f1e0d4ed9bfd324c58 (diff) | |
download | busybox-w32-02d650e15919e48fe031308c77c041159c0e3631.tar.gz busybox-w32-02d650e15919e48fe031308c77c041159c0e3631.tar.bz2 busybox-w32-02d650e15919e48fe031308c77c041159c0e3631.zip |
httpd: fix proxy headers passing - full_write() instead of write()
function old new delta
handle_incoming_and_exit 2763 2752 -11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/httpd.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index f713f6929..c486197b8 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -2271,15 +2271,20 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2271 | bb_error_msg("header: '%s'", iobuf); | 2271 | bb_error_msg("header: '%s'", iobuf); |
2272 | 2272 | ||
2273 | #if ENABLE_FEATURE_HTTPD_PROXY | 2273 | #if ENABLE_FEATURE_HTTPD_PROXY |
2274 | /* We need 2 more bytes for yet another "\r\n" - | 2274 | if (proxy_entry) { |
2275 | * see near fdprintf(proxy_fd...) further below */ | 2275 | /* Why 4, not 2? |
2276 | if (proxy_entry && (header_ptr - header_buf) < IOBUF_SIZE - 4) { | 2276 | * We need 2 more bytes for yet another "\r\n" - |
2277 | int len = strnlen(iobuf, IOBUF_SIZE - (header_ptr - header_buf) - 4); | 2277 | * see near fdprintf(proxy_fd...) further below. |
2278 | memcpy(header_ptr, iobuf, len); | 2278 | */ |
2279 | header_ptr += len; | 2279 | int maxlen = (IOBUF_SIZE-4) - (int)(header_ptr - header_buf); |
2280 | header_ptr[0] = '\r'; | 2280 | if (maxlen > 0) { |
2281 | header_ptr[1] = '\n'; | 2281 | int len = strnlen(iobuf, maxlen); |
2282 | header_ptr += 2; | 2282 | memcpy(header_ptr, iobuf, len); |
2283 | header_ptr += len; | ||
2284 | header_ptr[0] = '\r'; | ||
2285 | header_ptr[1] = '\n'; | ||
2286 | header_ptr += 2; | ||
2287 | } | ||
2283 | } | 2288 | } |
2284 | #endif | 2289 | #endif |
2285 | 2290 | ||
@@ -2401,7 +2406,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2401 | } | 2406 | } |
2402 | 2407 | ||
2403 | #if ENABLE_FEATURE_HTTPD_PROXY | 2408 | #if ENABLE_FEATURE_HTTPD_PROXY |
2404 | if (proxy_entry != NULL) { | 2409 | if (proxy_entry) { |
2405 | int proxy_fd; | 2410 | int proxy_fd; |
2406 | len_and_sockaddr *lsa; | 2411 | len_and_sockaddr *lsa; |
2407 | 2412 | ||
@@ -2423,7 +2428,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2423 | header_ptr[0] = '\r'; | 2428 | header_ptr[0] = '\r'; |
2424 | header_ptr[1] = '\n'; | 2429 | header_ptr[1] = '\n'; |
2425 | header_ptr += 2; | 2430 | header_ptr += 2; |
2426 | write(proxy_fd, header_buf, header_ptr - header_buf); | 2431 | full_write(proxy_fd, header_buf, header_ptr - header_buf); |
2427 | free(header_buf); /* on the order of 8k, free it */ | 2432 | free(header_buf); /* on the order of 8k, free it */ |
2428 | cgi_io_loop_and_exit(proxy_fd, proxy_fd, length); | 2433 | cgi_io_loop_and_exit(proxy_fd, proxy_fd, length); |
2429 | } | 2434 | } |