aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-04-09 11:24:09 +0100
committerRon Yorston <rmy@pobox.com>2023-04-09 11:24:09 +0100
commitd9f2ea8628452f787e02dd0e496af612a2e94578 (patch)
treec12be657e31c2e832b41fbff9a77aa0f886d47f0 /networking
parentfa04f2dc766c76f2caa44a4b8429185dde6a66b0 (diff)
parenta26711a2d1464167be4ebc990fe21a3809a2da34 (diff)
downloadbusybox-w32-d9f2ea8628452f787e02dd0e496af612a2e94578.tar.gz
busybox-w32-d9f2ea8628452f787e02dd0e496af612a2e94578.tar.bz2
busybox-w32-d9f2ea8628452f787e02dd0e496af612a2e94578.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'networking')
-rw-r--r--networking/httpd.c76
1 files changed, 39 insertions, 37 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index b32498ddb..302d1611d 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -2475,50 +2475,52 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
2475 send_headers_and_exit(HTTP_FORBIDDEN); 2475 send_headers_and_exit(HTTP_FORBIDDEN);
2476 } 2476 }
2477 cgi_type = CGI_NORMAL; 2477 cgi_type = CGI_NORMAL;
2478 } 2478 } /* why "else": do not check "cgi-bin/SCRIPT/something" for cases below: */
2479 else
2479#endif 2480#endif
2480 2481 {
2481 if (urlp[-1] == '/') { 2482 if (urlp[-1] == '/') {
2482 /* When index_page string is appended to <dir>/ URL, it overwrites 2483 /* When index_page string is appended to <dir>/ URL, it overwrites
2483 * the query string. If we fall back to call /cgi-bin/index.cgi, 2484 * the query string. If we fall back to call /cgi-bin/index.cgi,
2484 * query string would be lost and not available to the CGI. 2485 * query string would be lost and not available to the CGI.
2485 * Work around it by making a deep copy. 2486 * Work around it by making a deep copy.
2486 */ 2487 */
2487 if (ENABLE_FEATURE_HTTPD_CGI) 2488 if (ENABLE_FEATURE_HTTPD_CGI)
2488 g_query = xstrdup(g_query); /* ok for NULL too */ 2489 g_query = xstrdup(g_query); /* ok for NULL too */
2489 strcpy(urlp, index_page); 2490 strcpy(urlp, index_page);
2490 } 2491 }
2491 if (stat(tptr, &sb) == 0) { 2492 if (stat(tptr, &sb) == 0) {
2492 /* If URL is a directory with no slash, set up 2493 /* If URL is a directory with no slash, set up
2493 * "HTTP/1.1 302 Found" "Location: /dir/" reply */ 2494 * "HTTP/1.1 302 Found" "Location: /dir/" reply */
2494 if (urlp[-1] != '/' && S_ISDIR(sb.st_mode)) { 2495 if (urlp[-1] != '/' && S_ISDIR(sb.st_mode)) {
2495 found_moved_temporarily = urlcopy; 2496 found_moved_temporarily = urlcopy;
2496 } else { 2497 } else {
2497#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 2498#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
2498 char *suffix = strrchr(tptr, '.'); 2499 char *suffix = strrchr(tptr, '.');
2499 if (suffix) { 2500 if (suffix) {
2500 Htaccess *cur; 2501 Htaccess *cur;
2501 for (cur = script_i; cur; cur = cur->next) { 2502 for (cur = script_i; cur; cur = cur->next) {
2502 if (strcmp(cur->before_colon + 1, suffix) == 0) { 2503 if (strcmp(cur->before_colon + 1, suffix) == 0) {
2503 cgi_type = CGI_INTERPRETER; 2504 cgi_type = CGI_INTERPRETER;
2504 break; 2505 break;
2506 }
2505 } 2507 }
2506 } 2508 }
2507 }
2508#endif 2509#endif
2509 file_size = sb.st_size; 2510 file_size = sb.st_size;
2510 last_mod = sb.st_mtime; 2511 last_mod = sb.st_mtime;
2512 }
2511 } 2513 }
2512 }
2513#if ENABLE_FEATURE_HTTPD_CGI 2514#if ENABLE_FEATURE_HTTPD_CGI
2514 else if (urlp[-1] == '/') { 2515 else if (urlp[-1] == '/') {
2515 /* It's a dir URL and there is no index.html */ 2516 /* It's a dir URL and there is no index.html */
2516 /* Is there cgi-bin/index.cgi? */ 2517 /* Is there cgi-bin/index.cgi? */
2517 if (access("/cgi-bin/index.cgi"+1, X_OK) != 0) 2518 if (access("/cgi-bin/index.cgi"+1, X_OK) != 0)
2518 send_headers_and_exit(HTTP_NOT_FOUND); /* no */ 2519 send_headers_and_exit(HTTP_NOT_FOUND); /* no */
2519 cgi_type = CGI_INDEX; 2520 cgi_type = CGI_INDEX;
2520 } 2521 }
2521#endif 2522#endif
2523 }
2522 2524
2523#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CGI 2525#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CGI
2524 /* check_user_passwd() would be confused by added .../index.html, truncate it */ 2526 /* check_user_passwd() would be confused by added .../index.html, truncate it */
@@ -2787,8 +2789,8 @@ static void mini_httpd_nommu(int server_socket, int argc, char **argv)
2787 /* Run a copy of ourself in inetd mode */ 2789 /* Run a copy of ourself in inetd mode */
2788 re_exec(argv_copy); 2790 re_exec(argv_copy);
2789 } 2791 }
2790 argv_copy[0][0] &= 0x7f;
2791 /* parent, or vfork failed */ 2792 /* parent, or vfork failed */
2793 argv_copy[0][0] &= 0x7f; /* undo re_rexec() damage */
2792 close(n); 2794 close(n);
2793 } /* while (1) */ 2795 } /* while (1) */
2794 /* never reached */ 2796 /* never reached */