diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-18 15:14:36 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-18 15:14:36 +0000 |
commit | faf334aeb87ccc6680987bbd1fae8faf81969fed (patch) | |
tree | e7995e9b502be242f812cf4f9d693b23cda17d4f | |
parent | 9ddc8d54d18f33774dc9db80a26f82bbaff5747d (diff) | |
download | busybox-w32-faf334aeb87ccc6680987bbd1fae8faf81969fed.tar.gz busybox-w32-faf334aeb87ccc6680987bbd1fae8faf81969fed.tar.bz2 busybox-w32-faf334aeb87ccc6680987bbd1fae8faf81969fed.zip |
httpd: fix obscure case when user runs httpd -i from command line for testing.
(fixes bug 3334)
function old new delta
httpd_main 743 757 +14
handle_incoming_and_exit 2657 2669 +12
log_and_exit 75 43 -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 26/-32) Total: -6 bytes
-rw-r--r-- | networking/httpd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index f835d80ca..4094061a8 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -944,9 +944,12 @@ static void log_and_exit(void) | |||
944 | /* Paranoia. IE said to be buggy. It may send some extra data | 944 | /* Paranoia. IE said to be buggy. It may send some extra data |
945 | * or be confused by us just exiting without SHUT_WR. Oh well. */ | 945 | * or be confused by us just exiting without SHUT_WR. Oh well. */ |
946 | shutdown(1, SHUT_WR); | 946 | shutdown(1, SHUT_WR); |
947 | /* Why?? | ||
948 | (this also messes up stdin when user runs httpd -i from terminal) | ||
947 | ndelay_on(0); | 949 | ndelay_on(0); |
948 | while (read(0, iobuf, IOBUF_SIZE) > 0) | 950 | while (read(0, iobuf, IOBUF_SIZE) > 0) |
949 | continue; | 951 | continue; |
952 | */ | ||
950 | 953 | ||
951 | if (verbose > 2) | 954 | if (verbose > 2) |
952 | bb_error_msg("closed"); | 955 | bb_error_msg("closed"); |
@@ -1821,11 +1824,13 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
1821 | rmt_ip = ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[3]); | 1824 | rmt_ip = ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[3]); |
1822 | #endif | 1825 | #endif |
1823 | if (ENABLE_FEATURE_HTTPD_CGI || DEBUG || verbose) { | 1826 | if (ENABLE_FEATURE_HTTPD_CGI || DEBUG || verbose) { |
1827 | /* NB: can be NULL (user runs httpd -i by hand?) */ | ||
1824 | rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->u.sa); | 1828 | rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->u.sa); |
1825 | } | 1829 | } |
1826 | if (verbose) { | 1830 | if (verbose) { |
1827 | /* this trick makes -v logging much simpler */ | 1831 | /* this trick makes -v logging much simpler */ |
1828 | applet_name = rmt_ip_str; | 1832 | if (rmt_ip_str) |
1833 | applet_name = rmt_ip_str; | ||
1829 | if (verbose > 2) | 1834 | if (verbose > 2) |
1830 | bb_error_msg("connected"); | 1835 | bb_error_msg("connected"); |
1831 | } | 1836 | } |
@@ -2255,7 +2260,9 @@ static void mini_httpd_inetd(void) | |||
2255 | { | 2260 | { |
2256 | len_and_sockaddr fromAddr; | 2261 | len_and_sockaddr fromAddr; |
2257 | 2262 | ||
2263 | memset(&fromAddr, 0, sizeof(fromAddr)); | ||
2258 | fromAddr.len = LSA_SIZEOF_SA; | 2264 | fromAddr.len = LSA_SIZEOF_SA; |
2265 | /* NB: can fail if user runs it by hand and types in http cmds */ | ||
2259 | getpeername(0, &fromAddr.u.sa, &fromAddr.len); | 2266 | getpeername(0, &fromAddr.u.sa, &fromAddr.len); |
2260 | handle_incoming_and_exit(&fromAddr); | 2267 | handle_incoming_and_exit(&fromAddr); |
2261 | } | 2268 | } |