diff options
-rw-r--r-- | networking/httpd.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index ba956318c..f233cb0ba 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -348,7 +348,7 @@ struct globals { | |||
348 | #define range_len (G.range_len ) | 348 | #define range_len (G.range_len ) |
349 | #else | 349 | #else |
350 | enum { | 350 | enum { |
351 | range_start = 0, | 351 | range_start = -1, |
352 | range_end = MAXINT(off_t) - 1, | 352 | range_end = MAXINT(off_t) - 1, |
353 | range_len = MAXINT(off_t), | 353 | range_len = MAXINT(off_t), |
354 | }; | 354 | }; |
@@ -370,6 +370,7 @@ enum { | |||
370 | #define INIT_G() do { \ | 370 | #define INIT_G() do { \ |
371 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 371 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
372 | IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ | 372 | IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ |
373 | IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ | ||
373 | bind_addr_or_port = "80"; \ | 374 | bind_addr_or_port = "80"; \ |
374 | index_page = index_html; \ | 375 | index_page = index_html; \ |
375 | file_size = -1; \ | 376 | file_size = -1; \ |
@@ -1589,10 +1590,10 @@ static NOINLINE void send_file_and_exit(const char *url, int what) | |||
1589 | if (what == SEND_BODY /* err pages and ranges don't mix */ | 1590 | if (what == SEND_BODY /* err pages and ranges don't mix */ |
1590 | || content_gzip /* we are sending compressed page: can't do ranges */ ///why? | 1591 | || content_gzip /* we are sending compressed page: can't do ranges */ ///why? |
1591 | ) { | 1592 | ) { |
1592 | range_start = 0; | 1593 | range_start = -1; |
1593 | } | 1594 | } |
1594 | range_len = MAXINT(off_t); | 1595 | range_len = MAXINT(off_t); |
1595 | if (range_start) { | 1596 | if (range_start >= 0) { |
1596 | if (!range_end) { | 1597 | if (!range_end) { |
1597 | range_end = file_size - 1; | 1598 | range_end = file_size - 1; |
1598 | } | 1599 | } |
@@ -1600,7 +1601,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what) | |||
1600 | || lseek(fd, range_start, SEEK_SET) != range_start | 1601 | || lseek(fd, range_start, SEEK_SET) != range_start |
1601 | ) { | 1602 | ) { |
1602 | lseek(fd, 0, SEEK_SET); | 1603 | lseek(fd, 0, SEEK_SET); |
1603 | range_start = 0; | 1604 | range_start = -1; |
1604 | } else { | 1605 | } else { |
1605 | range_len = range_end - range_start + 1; | 1606 | range_len = range_end - range_start + 1; |
1606 | send_headers(HTTP_PARTIAL_CONTENT); | 1607 | send_headers(HTTP_PARTIAL_CONTENT); |
@@ -2168,11 +2169,11 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2168 | s += sizeof("bytes=")-1; | 2169 | s += sizeof("bytes=")-1; |
2169 | range_start = BB_STRTOOFF(s, &s, 10); | 2170 | range_start = BB_STRTOOFF(s, &s, 10); |
2170 | if (s[0] != '-' || range_start < 0) { | 2171 | if (s[0] != '-' || range_start < 0) { |
2171 | range_start = 0; | 2172 | range_start = -1; |
2172 | } else if (s[1]) { | 2173 | } else if (s[1]) { |
2173 | range_end = BB_STRTOOFF(s+1, NULL, 10); | 2174 | range_end = BB_STRTOOFF(s+1, NULL, 10); |
2174 | if (errno || range_end < range_start) | 2175 | if (errno || range_end < range_start) |
2175 | range_start = 0; | 2176 | range_start = -1; |
2176 | } | 2177 | } |
2177 | } | 2178 | } |
2178 | } | 2179 | } |