diff options
Diffstat (limited to 'networking')
-rw-r--r-- | networking/httpd.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 7e60fc252..a888c2424 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -163,7 +163,7 @@ enum { | |||
163 | #endif | 163 | #endif |
164 | }; | 164 | }; |
165 | 165 | ||
166 | static const uint16_t http_response_type[] = { | 166 | static const uint16_t http_response_type[] ALIGN2 = { |
167 | HTTP_OK, | 167 | HTTP_OK, |
168 | HTTP_MOVED_TEMPORARILY, | 168 | HTTP_MOVED_TEMPORARILY, |
169 | HTTP_REQUEST_TIMEOUT, | 169 | HTTP_REQUEST_TIMEOUT, |
@@ -287,8 +287,6 @@ struct globals { | |||
287 | } while (0) | 287 | } while (0) |
288 | 288 | ||
289 | 289 | ||
290 | |||
291 | |||
292 | #define STRNCASECMP(a, str) strncasecmp((a), (str), sizeof(str)-1) | 290 | #define STRNCASECMP(a, str) strncasecmp((a), (str), sizeof(str)-1) |
293 | 291 | ||
294 | /* Prototypes */ | 292 | /* Prototypes */ |
@@ -467,11 +465,6 @@ static void parse_conf(const char *path, int flag) | |||
467 | 465 | ||
468 | if (flag == SUBDIR_PARSE || cf == NULL) { | 466 | if (flag == SUBDIR_PARSE || cf == NULL) { |
469 | cf = alloca(strlen(path) + sizeof(httpd_conf) + 2); | 467 | cf = alloca(strlen(path) + sizeof(httpd_conf) + 2); |
470 | if (cf == NULL) { | ||
471 | if (flag == FIRST_PARSE) | ||
472 | bb_error_msg_and_die(bb_msg_memory_exhausted); | ||
473 | return; | ||
474 | } | ||
475 | sprintf((char *)cf, "%s/%s", path, httpd_conf); | 468 | sprintf((char *)cf, "%s/%s", path, httpd_conf); |
476 | } | 469 | } |
477 | 470 | ||
@@ -554,7 +547,7 @@ static void parse_conf(const char *path, int flag) | |||
554 | /* error status code */ | 547 | /* error status code */ |
555 | int status = atoi(++p0); | 548 | int status = atoi(++p0); |
556 | /* c already points at the character following ':' in parse loop */ | 549 | /* c already points at the character following ':' in parse loop */ |
557 | // c = strchr(p0, ':'); c++; | 550 | /* c = strchr(p0, ':'); c++; */ |
558 | if (status < HTTP_CONTINUE) { | 551 | if (status < HTTP_CONTINUE) { |
559 | bb_error_msg("config error '%s' in '%s'", buf, cf); | 552 | bb_error_msg("config error '%s' in '%s'", buf, cf); |
560 | continue; | 553 | continue; |
@@ -575,9 +568,7 @@ static void parse_conf(const char *path, int flag) | |||
575 | if (*p0 == '/') { | 568 | if (*p0 == '/') { |
576 | /* make full path from httpd root / current_path / config_line_path */ | 569 | /* make full path from httpd root / current_path / config_line_path */ |
577 | cf = (flag == SUBDIR_PARSE ? path : ""); | 570 | cf = (flag == SUBDIR_PARSE ? path : ""); |
578 | p0 = malloc(strlen(cf) + (c - buf) + 2 + strlen(c)); | 571 | p0 = xmalloc(strlen(cf) + (c - buf) + 2 + strlen(c)); |
579 | if (p0 == NULL) | ||
580 | continue; | ||
581 | c[-1] = '\0'; | 572 | c[-1] = '\0'; |
582 | sprintf(p0, "/%s%s", cf, buf); | 573 | sprintf(p0, "/%s%s", cf, buf); |
583 | 574 | ||
@@ -694,9 +685,11 @@ static char *encodeString(const char *string) | |||
694 | char ch; | 685 | char ch; |
695 | 686 | ||
696 | while ((ch = *string++)) { | 687 | while ((ch = *string++)) { |
697 | // very simple check for what to encode | 688 | /* very simple check for what to encode */ |
698 | if (isalnum(ch)) *p++ = ch; | 689 | if (isalnum(ch)) |
699 | else p += sprintf(p, "&#%d;", (unsigned char) ch); | 690 | *p++ = ch; |
691 | else | ||
692 | p += sprintf(p, "&#%d;", (unsigned char) ch); | ||
700 | } | 693 | } |
701 | *p = '\0'; | 694 | *p = '\0'; |
702 | return out; | 695 | return out; |
@@ -717,18 +710,21 @@ static char *encodeString(const char *string) | |||
717 | */ | 710 | */ |
718 | static unsigned hex_to_bin(unsigned char c) | 711 | static unsigned hex_to_bin(unsigned char c) |
719 | { | 712 | { |
720 | unsigned v = c | 0x20; /* lowercase */ | 713 | unsigned v; |
721 | v = v - '0'; | 714 | |
715 | v = c - '0'; | ||
722 | if (v <= 9) | 716 | if (v <= 9) |
723 | return v; | 717 | return v; |
724 | v = v + ('0' - 'a'); | 718 | /* c | 0x20: letters to lower case, non-letters |
719 | * to (potentially different) non-letters */ | ||
720 | v = (unsigned)(c | 0x20) - 'a'; | ||
725 | if (v <= 5) | 721 | if (v <= 5) |
726 | return v + 10; | 722 | return v + 10; |
727 | return ~0; | 723 | return ~0; |
728 | } | 724 | } |
729 | /* For testing: | 725 | /* For testing: |
730 | void t(char c) { printf("'%c' %u\n", c, hex_to_bin(c)); } | 726 | void t(char c) { printf("'%c'(%u) %u\n", c, c, hex_to_bin(c)); } |
731 | int main() { t('0'); t('9'); t('A'); t('F'); t('a'); t('f'); | 727 | int main() { t(0x10); t(0x20); t('0'); t('9'); t('A'); t('F'); t('a'); t('f'); |
732 | t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; } | 728 | t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; } |
733 | */ | 729 | */ |
734 | static char *decodeString(char *orig, int option_d) | 730 | static char *decodeString(char *orig, int option_d) |