diff options
author | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
commit | 89963b524d211e1aec12b72b3725be05ee95c8cf (patch) | |
tree | 48590aef62b7ee7686b7898256f29def8d9c50b9 /networking/httpd.c | |
parent | 9aa5a829070392c2ac6494d0c4e674c0c2bc7dab (diff) | |
parent | 2b7c1aa92c68524559a2067609d09309d5c09adc (diff) | |
download | busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.gz busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.bz2 busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'networking/httpd.c')
-rw-r--r-- | networking/httpd.c | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index daa3ca1d0..02f544593 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -305,6 +305,11 @@ | |||
305 | # include <sys/sendfile.h> | 305 | # include <sys/sendfile.h> |
306 | #endif | 306 | #endif |
307 | 307 | ||
308 | /* see sys/netinet6/in6.h */ | ||
309 | #if defined(__FreeBSD__) | ||
310 | # define s6_addr32 __u6_addr.__u6_addr32 | ||
311 | #endif | ||
312 | |||
308 | #define DEBUG 0 | 313 | #define DEBUG 0 |
309 | 314 | ||
310 | #define IOBUF_SIZE 8192 | 315 | #define IOBUF_SIZE 8192 |
@@ -1036,48 +1041,9 @@ static char *encodeString(const char *string) | |||
1036 | * Parameter: a pointer to a base64 encoded string. | 1041 | * Parameter: a pointer to a base64 encoded string. |
1037 | * Decoded data is stored in-place. | 1042 | * Decoded data is stored in-place. |
1038 | */ | 1043 | */ |
1039 | static void decodeBase64(char *Data) | 1044 | static void decodeBase64(char *data) |
1040 | { | 1045 | { |
1041 | # if ENABLE_BASE64 || ENABLE_UUDECODE | 1046 | decode_base64(data, NULL)[0] = '\0'; |
1042 | /* Call decode_base64() from uuencode.c */ | ||
1043 | char *eptr = Data; | ||
1044 | decode_base64(&eptr, Data); | ||
1045 | *eptr = '\0'; | ||
1046 | # else | ||
1047 | const unsigned char *in = (const unsigned char *)Data; | ||
1048 | /* The decoded size will be at most 3/4 the size of the encoded */ | ||
1049 | unsigned ch = 0; | ||
1050 | int i = 0; | ||
1051 | |||
1052 | while (*in) { | ||
1053 | int t = *in++; | ||
1054 | |||
1055 | if (t >= '0' && t <= '9') | ||
1056 | t = t - '0' + 52; | ||
1057 | else if (t >= 'A' && t <= 'Z') | ||
1058 | t = t - 'A'; | ||
1059 | else if (t >= 'a' && t <= 'z') | ||
1060 | t = t - 'a' + 26; | ||
1061 | else if (t == '+') | ||
1062 | t = 62; | ||
1063 | else if (t == '/') | ||
1064 | t = 63; | ||
1065 | else if (t == '=') | ||
1066 | t = 0; | ||
1067 | else | ||
1068 | continue; | ||
1069 | |||
1070 | ch = (ch << 6) | t; | ||
1071 | i++; | ||
1072 | if (i == 4) { | ||
1073 | *Data++ = (char) (ch >> 16); | ||
1074 | *Data++ = (char) (ch >> 8); | ||
1075 | *Data++ = (char) ch; | ||
1076 | i = 0; | ||
1077 | } | ||
1078 | } | ||
1079 | *Data = '\0'; | ||
1080 | # endif | ||
1081 | } | 1047 | } |
1082 | #endif | 1048 | #endif |
1083 | 1049 | ||
@@ -1945,7 +1911,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what) | |||
1945 | send_headers(HTTP_OK); | 1911 | send_headers(HTTP_OK); |
1946 | #if ENABLE_FEATURE_USE_SENDFILE | 1912 | #if ENABLE_FEATURE_USE_SENDFILE |
1947 | { | 1913 | { |
1948 | off_t offset = range_start; | 1914 | off_t offset = (range_start < 0) ? 0 : range_start; |
1949 | while (1) { | 1915 | while (1) { |
1950 | /* sz is rounded down to 64k */ | 1916 | /* sz is rounded down to 64k */ |
1951 | ssize_t sz = MAXINT(ssize_t) - 0xffff; | 1917 | ssize_t sz = MAXINT(ssize_t) - 0xffff; |
@@ -2590,8 +2556,8 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2590 | if (STRNCASECMP(iobuf, "Range:") == 0) { | 2556 | if (STRNCASECMP(iobuf, "Range:") == 0) { |
2591 | /* We know only bytes=NNN-[MMM] */ | 2557 | /* We know only bytes=NNN-[MMM] */ |
2592 | char *s = skip_whitespace(iobuf + sizeof("Range:")-1); | 2558 | char *s = skip_whitespace(iobuf + sizeof("Range:")-1); |
2593 | if (is_prefixed_with(s, "bytes=")) { | 2559 | s = is_prefixed_with(s, "bytes="); |
2594 | s += sizeof("bytes=")-1; | 2560 | if (s) { |
2595 | range_start = BB_STRTOOFF(s, &s, 10); | 2561 | range_start = BB_STRTOOFF(s, &s, 10); |
2596 | if (s[0] != '-' || range_start < 0) { | 2562 | if (s[0] != '-' || range_start < 0) { |
2597 | range_start = -1; | 2563 | range_start = -1; |