diff options
| -rw-r--r-- | networking/httpd.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index fc52fafea..e48574e4f 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
| @@ -679,7 +679,7 @@ enum { | |||
| 679 | SIGNALED_PARSE = 1, /* path will be "/etc" */ | 679 | SIGNALED_PARSE = 1, /* path will be "/etc" */ |
| 680 | SUBDIR_PARSE = 2, /* path will be derived from URL */ | 680 | SUBDIR_PARSE = 2, /* path will be derived from URL */ |
| 681 | }; | 681 | }; |
| 682 | static void parse_conf(const char *path, int flag) | 682 | static int parse_conf(const char *path, int flag) |
| 683 | { | 683 | { |
| 684 | /* internally used extra flag state */ | 684 | /* internally used extra flag state */ |
| 685 | enum { TRY_CURDIR_PARSE = 3 }; | 685 | enum { TRY_CURDIR_PARSE = 3 }; |
| @@ -713,7 +713,7 @@ static void parse_conf(const char *path, int flag) | |||
| 713 | while ((f = fopen_for_read(filename)) == NULL) { | 713 | while ((f = fopen_for_read(filename)) == NULL) { |
| 714 | if (flag >= SUBDIR_PARSE) { /* SUBDIR or TRY_CURDIR */ | 714 | if (flag >= SUBDIR_PARSE) { /* SUBDIR or TRY_CURDIR */ |
| 715 | /* config file not found, no changes to config */ | 715 | /* config file not found, no changes to config */ |
| 716 | return; | 716 | return -1; |
| 717 | } | 717 | } |
| 718 | if (flag == FIRST_PARSE) { | 718 | if (flag == FIRST_PARSE) { |
| 719 | /* -c CONFFILE given, but CONFFILE doesn't exist? */ | 719 | /* -c CONFFILE given, but CONFFILE doesn't exist? */ |
| @@ -971,6 +971,7 @@ static void parse_conf(const char *path, int flag) | |||
| 971 | } /* while (fgets) */ | 971 | } /* while (fgets) */ |
| 972 | 972 | ||
| 973 | fclose(f); | 973 | fclose(f); |
| 974 | return 0; | ||
| 974 | } | 975 | } |
| 975 | 976 | ||
| 976 | #if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR | 977 | #if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR |
| @@ -2363,12 +2364,9 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
| 2363 | while ((tptr = strchr(tptr + 1, '/')) != NULL) { | 2364 | while ((tptr = strchr(tptr + 1, '/')) != NULL) { |
| 2364 | /* have path1/path2 */ | 2365 | /* have path1/path2 */ |
| 2365 | *tptr = '\0'; | 2366 | *tptr = '\0'; |
| 2366 | //TODO: can we avoid is_directory() test here? | 2367 | /* may have subdir config */ |
| 2367 | if (is_directory(urlcopy + 1, /*followlinks:*/ 1)) { | 2368 | if (parse_conf(urlcopy + 1, SUBDIR_PARSE) == 0) |
| 2368 | /* may have subdir config */ | ||
| 2369 | parse_conf(urlcopy + 1, SUBDIR_PARSE); | ||
| 2370 | if_ip_denied_send_HTTP_FORBIDDEN_and_exit(remote_ip); | 2369 | if_ip_denied_send_HTTP_FORBIDDEN_and_exit(remote_ip); |
| 2371 | } | ||
| 2372 | *tptr = '/'; | 2370 | *tptr = '/'; |
| 2373 | } | 2371 | } |
| 2374 | 2372 | ||
| @@ -2420,9 +2418,9 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
| 2420 | else if (urlp[-1] == '/') { | 2418 | else if (urlp[-1] == '/') { |
| 2421 | /* It's a dir URL and there is no index.html | 2419 | /* It's a dir URL and there is no index.html |
| 2422 | * Try cgi-bin/index.cgi */ | 2420 | * Try cgi-bin/index.cgi */ |
| 2423 | if (access("/cgi-bin/index.cgi"+1, X_OK) == 0) { | 2421 | if (access("/cgi-bin/index.cgi"+1, X_OK) != 0) |
| 2424 | cgi_type = CGI_INDEX; | 2422 | send_headers_and_exit(HTTP_NOT_FOUND); |
| 2425 | } | 2423 | cgi_type = CGI_INDEX; |
| 2426 | } | 2424 | } |
| 2427 | #endif | 2425 | #endif |
| 2428 | urlp[0] = '\0'; | 2426 | urlp[0] = '\0'; |
