aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/httpd.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 66ce1e1f7..01b56ebd2 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1059,6 +1059,7 @@ static int get_line(void)
1059 int count = 0; 1059 int count = 0;
1060 char c; 1060 char c;
1061 1061
1062 alarm(HEADER_READ_TIMEOUT);
1062 while (1) { 1063 while (1) {
1063 if (hdr_cnt <= 0) { 1064 if (hdr_cnt <= 0) {
1064 hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf)); 1065 hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
@@ -1073,7 +1074,7 @@ static int get_line(void)
1073 continue; 1074 continue;
1074 if (c == '\n') { 1075 if (c == '\n') {
1075 iobuf[count] = '\0'; 1076 iobuf[count] = '\0';
1076 return count; 1077 break;
1077 } 1078 }
1078 if (count < (IOBUF_SIZE - 1)) /* check overflow */ 1079 if (count < (IOBUF_SIZE - 1)) /* check overflow */
1079 count++; 1080 count++;
@@ -1739,8 +1740,8 @@ static Htaccess_Proxy *find_proxy_entry(const char *url)
1739/* 1740/*
1740 * Handle timeouts 1741 * Handle timeouts
1741 */ 1742 */
1742static void exit_on_signal(int sig) NORETURN; 1743static void send_REQUEST_TIMEOUT_and_exit(int sig) NORETURN;
1743static void exit_on_signal(int sig UNUSED_PARAM) 1744static void send_REQUEST_TIMEOUT_and_exit(int sig UNUSED_PARAM)
1744{ 1745{
1745 send_headers_and_exit(HTTP_REQUEST_TIMEOUT); 1746 send_headers_and_exit(HTTP_REQUEST_TIMEOUT);
1746} 1747}
@@ -1805,9 +1806,8 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
1805 bb_error_msg("connected"); 1806 bb_error_msg("connected");
1806 } 1807 }
1807 1808
1808 /* Install timeout handler */ 1809 /* Install timeout handler. get_line() needs it. */
1809 signal_no_SA_RESTART_empty_mask(SIGALRM, exit_on_signal); 1810 signal(SIGALRM, send_REQUEST_TIMEOUT_and_exit);
1810 alarm(HEADER_READ_TIMEOUT);
1811 1811
1812 if (!get_line()) /* EOF or error or empty line */ 1812 if (!get_line()) /* EOF or error or empty line */
1813 send_headers_and_exit(HTTP_BAD_REQUEST); 1813 send_headers_and_exit(HTTP_BAD_REQUEST);
@@ -1934,7 +1934,6 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
1934 1934
1935 /* Read until blank line for HTTP version specified, else parse immediate */ 1935 /* Read until blank line for HTTP version specified, else parse immediate */
1936 while (1) { 1936 while (1) {
1937 alarm(HEADER_READ_TIMEOUT);
1938 if (!get_line()) 1937 if (!get_line())
1939 break; /* EOF or error or empty line */ 1938 break; /* EOF or error or empty line */
1940 if (DEBUG) 1939 if (DEBUG)