diff options
author | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-12-02 09:46:04 +0000 |
---|---|---|
committer | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-12-02 09:46:04 +0000 |
commit | 27d42a08c817c01fc49cbe1556ed6dbf13d9dc45 (patch) | |
tree | 0b604746209e749b4b93a46108311c603dbe4677 | |
parent | 4a070d1460456117e4286734682ec6462499edfe (diff) | |
download | busybox-w32-27d42a08c817c01fc49cbe1556ed6dbf13d9dc45.tar.gz busybox-w32-27d42a08c817c01fc49cbe1556ed6dbf13d9dc45.tar.bz2 busybox-w32-27d42a08c817c01fc49cbe1556ed6dbf13d9dc45.zip |
remove warnings if compile with -W, use ENABLE_FEATURE vs CONFIG_FEATURE
-rw-r--r-- | networking/httpd.c | 126 |
1 files changed, 64 insertions, 62 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 64c374542..11e89f64a 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -326,7 +326,7 @@ typedef struct | |||
326 | } HttpEnumString; | 326 | } HttpEnumString; |
327 | 327 | ||
328 | static const HttpEnumString httpResponseNames[] = { | 328 | static const HttpEnumString httpResponseNames[] = { |
329 | { HTTP_OK, "OK" }, | 329 | { HTTP_OK, "OK", NULL }, |
330 | { HTTP_MOVED_TEMPORARILY, "Found", "Directories must end with a slash." }, | 330 | { HTTP_MOVED_TEMPORARILY, "Found", "Directories must end with a slash." }, |
331 | { HTTP_REQUEST_TIMEOUT, "Request Timeout", | 331 | { HTTP_REQUEST_TIMEOUT, "Request Timeout", |
332 | "No request appeared within a reasonable time period." }, | 332 | "No request appeared within a reasonable time period." }, |
@@ -673,7 +673,7 @@ static void parse_conf(const char *path, int flag) | |||
673 | } else { | 673 | } else { |
674 | /* sort path, if current lenght eq or bigger then move up */ | 674 | /* sort path, if current lenght eq or bigger then move up */ |
675 | Htaccess *prev_hti = config->auth; | 675 | Htaccess *prev_hti = config->auth; |
676 | int l = strlen(cf); | 676 | size_t l = strlen(cf); |
677 | Htaccess *hti; | 677 | Htaccess *hti; |
678 | 678 | ||
679 | for(hti = prev_hti; hti; hti = hti->next) { | 679 | for(hti = prev_hti; hti; hti = hti->next) { |
@@ -852,7 +852,7 @@ static void addEnvPort(const char *port_name) | |||
852 | static void decodeBase64(char *Data) | 852 | static void decodeBase64(char *Data) |
853 | { | 853 | { |
854 | 854 | ||
855 | const unsigned char *in = Data; | 855 | const unsigned char *in = (const unsigned char *)Data; |
856 | // The decoded size will be at most 3/4 the size of the encoded | 856 | // The decoded size will be at most 3/4 the size of the encoded |
857 | unsigned long ch = 0; | 857 | unsigned long ch = 0; |
858 | int i = 0; | 858 | int i = 0; |
@@ -1268,7 +1268,7 @@ static int sendCgi(const char *url, | |||
1268 | post_readed_size = post_readed_idx = bodyLen = 0; /* broken pipe to CGI */ | 1268 | post_readed_size = post_readed_idx = bodyLen = 0; /* broken pipe to CGI */ |
1269 | } | 1269 | } |
1270 | } else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) { | 1270 | } else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) { |
1271 | count = bodyLen > sizeof(wbuf) ? sizeof(wbuf) : bodyLen; | 1271 | count = bodyLen > (int)sizeof(wbuf) ? (int)sizeof(wbuf) : bodyLen; |
1272 | count = safe_read(a_c_r, wbuf, count); | 1272 | count = safe_read(a_c_r, wbuf, count); |
1273 | if(count > 0) { | 1273 | if(count > 0) { |
1274 | post_readed_size += count; | 1274 | post_readed_size += count; |
@@ -1456,7 +1456,7 @@ static int checkPerm(const char *path, const char *request) | |||
1456 | fprintf(stderr,"checkPerm: '%s' ? '%s'\n", p0, request); | 1456 | fprintf(stderr,"checkPerm: '%s' ? '%s'\n", p0, request); |
1457 | #endif | 1457 | #endif |
1458 | { | 1458 | { |
1459 | int l = strlen(p0); | 1459 | size_t l = strlen(p0); |
1460 | 1460 | ||
1461 | if(strncmp(p0, path, l) == 0 && | 1461 | if(strncmp(p0, path, l) == 0 && |
1462 | (l == 1 || path[l] == '/' || path[l] == 0)) { | 1462 | (l == 1 || path[l] == '/' || path[l] == 0)) { |
@@ -1664,53 +1664,57 @@ BAD_REQUEST: | |||
1664 | } | 1664 | } |
1665 | *test = '/'; | 1665 | *test = '/'; |
1666 | } | 1666 | } |
1667 | 1667 | if(blank >= 0) { | |
1668 | // read until blank line for HTTP version specified, else parse immediate | 1668 | // read until blank line for HTTP version specified, else parse immediate |
1669 | while (blank >= 0 && alarm(TIMEOUT) >= 0 && (count = getLine()) > 0) { | 1669 | while(1) { |
1670 | alarm(TIMEOUT); | ||
1671 | count = getLine(); | ||
1672 | if(count <= 0) | ||
1673 | break; | ||
1670 | 1674 | ||
1671 | #ifdef DEBUG | 1675 | #ifdef DEBUG |
1672 | if (config->debugHttpd) fprintf(stderr, "Header: '%s'\n", buf); | 1676 | if (config->debugHttpd) fprintf(stderr, "Header: '%s'\n", buf); |
1673 | #endif | 1677 | #endif |
1674 | 1678 | ||
1675 | #ifdef CONFIG_FEATURE_HTTPD_CGI | 1679 | #ifdef CONFIG_FEATURE_HTTPD_CGI |
1676 | /* try and do our best to parse more lines */ | 1680 | /* try and do our best to parse more lines */ |
1677 | if ((strncasecmp(buf, Content_length, 15) == 0)) { | 1681 | if ((strncasecmp(buf, Content_length, 15) == 0)) { |
1678 | if(prequest != request_GET) | 1682 | if(prequest != request_GET) |
1679 | length = strtol(buf + 15, 0, 0); // extra read only for POST | 1683 | length = strtol(buf + 15, 0, 0); // extra read only for POST |
1680 | } else if ((strncasecmp(buf, "Cookie:", 7) == 0)) { | 1684 | } else if ((strncasecmp(buf, "Cookie:", 7) == 0)) { |
1681 | for(test = buf + 7; isspace(*test); test++) | 1685 | for(test = buf + 7; isspace(*test); test++) |
1682 | ; | 1686 | ; |
1683 | cookie = strdup(test); | 1687 | cookie = strdup(test); |
1684 | } else if ((strncasecmp(buf, "Content-Type:", 13) == 0)) { | 1688 | } else if ((strncasecmp(buf, "Content-Type:", 13) == 0)) { |
1685 | for(test = buf + 13; isspace(*test); test++) | 1689 | for(test = buf + 13; isspace(*test); test++) |
1686 | ; | 1690 | ; |
1687 | content_type = strdup(test); | 1691 | content_type = strdup(test); |
1688 | } else if ((strncasecmp(buf, "Referer:", 8) == 0)) { | 1692 | } else if ((strncasecmp(buf, "Referer:", 8) == 0)) { |
1689 | for(test = buf + 8; isspace(*test); test++) | 1693 | for(test = buf + 8; isspace(*test); test++) |
1690 | ; | 1694 | ; |
1691 | config->referer = strdup(test); | 1695 | config->referer = strdup(test); |
1692 | } | 1696 | } |
1693 | #endif | 1697 | #endif |
1694 | 1698 | ||
1695 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1699 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH |
1696 | if (strncasecmp(buf, "Authorization:", 14) == 0) { | 1700 | if (strncasecmp(buf, "Authorization:", 14) == 0) { |
1697 | /* We only allow Basic credentials. | 1701 | /* We only allow Basic credentials. |
1698 | * It shows up as "Authorization: Basic <userid:password>" where | 1702 | * It shows up as "Authorization: Basic <userid:password>" where |
1699 | * the userid:password is base64 encoded. | 1703 | * the userid:password is base64 encoded. |
1700 | */ | 1704 | */ |
1701 | for(test = buf + 14; isspace(*test); test++) | 1705 | for(test = buf + 14; isspace(*test); test++) |
1702 | ; | 1706 | ; |
1703 | if (strncasecmp(test, "Basic", 5) != 0) | 1707 | if (strncasecmp(test, "Basic", 5) != 0) |
1704 | continue; | 1708 | continue; |
1705 | 1709 | ||
1706 | test += 5; /* decodeBase64() skiping space self */ | 1710 | test += 5; /* decodeBase64() skiping space self */ |
1707 | decodeBase64(test); | 1711 | decodeBase64(test); |
1708 | credentials = checkPerm(url, test); | 1712 | credentials = checkPerm(url, test); |
1709 | } | 1713 | } |
1710 | #endif /* CONFIG_FEATURE_HTTPD_BASIC_AUTH */ | 1714 | #endif /* CONFIG_FEATURE_HTTPD_BASIC_AUTH */ |
1711 | 1715 | ||
1712 | } /* while extra header reading */ | 1716 | } /* while extra header reading */ |
1713 | 1717 | } | |
1714 | (void) alarm( 0 ); | 1718 | (void) alarm( 0 ); |
1715 | if(config->alarm_signaled) | 1719 | if(config->alarm_signaled) |
1716 | break; | 1720 | break; |
@@ -1927,38 +1931,36 @@ static void sighup_handler(int sig) | |||
1927 | static const char httpd_opts[]="c:d:h:" | 1931 | static const char httpd_opts[]="c:d:h:" |
1928 | #ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR | 1932 | #ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR |
1929 | "e:" | 1933 | "e:" |
1930 | #define OPT_INC_1 1 | ||
1931 | #else | ||
1932 | #define OPT_INC_1 0 | ||
1933 | #endif | 1934 | #endif |
1935 | #define OPT_INC_1 ENABLE_FEATURE_HTTPD_ENCODE_URL_STR | ||
1936 | |||
1934 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH | 1937 | #ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH |
1935 | "r:" | 1938 | "r:" |
1936 | # ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5 | ||
1937 | "m:" | ||
1938 | # define OPT_INC_2 2 | ||
1939 | # else | ||
1940 | # define OPT_INC_2 1 | ||
1941 | #endif | 1939 | #endif |
1942 | #else | 1940 | #define OPT_INC_2 ENABLE_FEATURE_HTTPD_BASIC_AUTH |
1943 | #define OPT_INC_2 0 | 1941 | |
1942 | #ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5 | ||
1943 | "m:" | ||
1944 | #endif | 1944 | #endif |
1945 | #define OPT_INC_3 ENABLE_FEATURE_HTTPD_AUTH_MD5 | ||
1946 | |||
1945 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1947 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY |
1946 | "p:v" | 1948 | "p:v" |
1949 | #endif | ||
1947 | #ifdef CONFIG_FEATURE_HTTPD_SETUID | 1950 | #ifdef CONFIG_FEATURE_HTTPD_SETUID |
1948 | "u:" | 1951 | "u:" |
1949 | #endif | 1952 | #endif |
1950 | #endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */ | ||
1951 | ; | 1953 | ; |
1952 | 1954 | ||
1953 | #define OPT_CONFIG_FILE (1<<0) | 1955 | #define OPT_CONFIG_FILE (1<<0) /* c */ |
1954 | #define OPT_DECODE_URL (1<<1) | 1956 | #define OPT_DECODE_URL (1<<1) /* d */ |
1955 | #define OPT_HOME_HTTPD (1<<2) | 1957 | #define OPT_HOME_HTTPD (1<<2) /* h */ |
1956 | #define OPT_ENCODE_URL (1<<(2+OPT_INC_1)) | 1958 | #define OPT_ENCODE_URL (1<<(2+OPT_INC_1)) /* e */ |
1957 | #define OPT_REALM (1<<(3+OPT_INC_1)) | 1959 | #define OPT_REALM (1<<(2+OPT_INC_1+OPT_INC_2)) /* r */ |
1958 | #define OPT_MD5 (1<<(4+OPT_INC_1)) | 1960 | #define OPT_MD5 (1<<(2+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* m */ |
1959 | #define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2)) | 1961 | #define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* p */ |
1960 | #define OPT_DEBUG (1<<(4+OPT_INC_1+OPT_INC_2)) | 1962 | #define OPT_DEBUG (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* v */ |
1961 | #define OPT_SETUID (1<<(5+OPT_INC_1+OPT_INC_2)) | 1963 | #define OPT_SETUID (1<<(5+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* u */ |
1962 | 1964 | ||
1963 | 1965 | ||
1964 | #ifdef HTTPD_STANDALONE | 1966 | #ifdef HTTPD_STANDALONE |