aboutsummaryrefslogtreecommitdiff
path: root/networking/httpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-04-19 14:02:51 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-04-19 14:02:51 +0200
commitbca888a73ef755e7fe52ac7aff5bd884f71d32f9 (patch)
tree497a00454f45db71c6f9847fbc008622570f3bdc /networking/httpd.c
parentad29ba73ee00d4c78b3ab85a6b943a8c63075f50 (diff)
downloadbusybox-w32-bca888a73ef755e7fe52ac7aff5bd884f71d32f9.tar.gz
busybox-w32-bca888a73ef755e7fe52ac7aff5bd884f71d32f9.tar.bz2
busybox-w32-bca888a73ef755e7fe52ac7aff5bd884f71d32f9.zip
httpd: deindent code block, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r--networking/httpd.c182
1 files changed, 91 insertions, 91 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index f8a1e2556..d06bc2776 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -2364,121 +2364,121 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
2364 total_headers_len = 0; 2364 total_headers_len = 0;
2365#endif 2365#endif
2366 2366
2367 /* Read until blank line */ 2367 /* Read until blank line */
2368 while (1) { 2368 while (1) {
2369 unsigned iobuf_len = get_line(); 2369 unsigned iobuf_len = get_line();
2370 if (!iobuf_len) 2370 if (!iobuf_len)
2371 break; /* EOF or error or empty line */ 2371 break; /* EOF or error or empty line */
2372#if ENABLE_FEATURE_HTTPD_CGI 2372#if ENABLE_FEATURE_HTTPD_CGI
2373 /* Prevent unlimited growth of HTTP_xyz envvars */ 2373 /* Prevent unlimited growth of HTTP_xyz envvars */
2374 total_headers_len += iobuf_len; 2374 total_headers_len += iobuf_len;
2375 if (total_headers_len >= MAX_HTTP_HEADERS_SIZE) 2375 if (total_headers_len >= MAX_HTTP_HEADERS_SIZE)
2376 send_headers_and_exit(HTTP_ENTITY_TOO_LARGE); 2376 send_headers_and_exit(HTTP_ENTITY_TOO_LARGE);
2377#endif 2377#endif
2378 if (DEBUG) 2378 if (DEBUG)
2379 bb_error_msg("header: '%s'", iobuf); 2379 bb_error_msg("header: '%s'", iobuf);
2380#if ENABLE_FEATURE_HTTPD_CGI || ENABLE_FEATURE_HTTPD_PROXY 2380#if ENABLE_FEATURE_HTTPD_CGI || ENABLE_FEATURE_HTTPD_PROXY
2381 /* Try and do our best to parse more lines */ 2381 /* Try and do our best to parse more lines */
2382 if (STRNCASECMP(iobuf, "Content-Length:") == 0) { 2382 if (STRNCASECMP(iobuf, "Content-Length:") == 0) {
2383 /* extra read only for POST */ 2383 /* extra read only for POST */
2384 if (prequest != request_GET 2384 if (prequest != request_GET
2385# if ENABLE_FEATURE_HTTPD_CGI 2385# if ENABLE_FEATURE_HTTPD_CGI
2386 && prequest != request_HEAD 2386 && prequest != request_HEAD
2387# endif 2387# endif
2388 ) { 2388 ) {
2389 tptr = skip_whitespace(iobuf + sizeof("Content-Length:") - 1); 2389 tptr = skip_whitespace(iobuf + sizeof("Content-Length:") - 1);
2390 if (!tptr[0]) 2390 if (!tptr[0])
2391 send_headers_and_exit(HTTP_BAD_REQUEST); 2391 send_headers_and_exit(HTTP_BAD_REQUEST);
2392 /* not using strtoul: it ignores leading minus! */ 2392 /* not using strtoul: it ignores leading minus! */
2393 length = bb_strtou(tptr, NULL, 10); 2393 length = bb_strtou(tptr, NULL, 10);
2394 /* length is "ulong", but we need to pass it to int later */ 2394 /* length is "ulong", but we need to pass it to int later */
2395 if (errno || length > INT_MAX) 2395 if (errno || length > INT_MAX)
2396 send_headers_and_exit(HTTP_BAD_REQUEST); 2396 send_headers_and_exit(HTTP_BAD_REQUEST);
2397 }
2398 continue;
2399 } 2397 }
2398 continue;
2399 }
2400#endif 2400#endif
2401#if ENABLE_FEATURE_HTTPD_BASIC_AUTH 2401#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
2402 if (STRNCASECMP(iobuf, "Authorization:") == 0) { 2402 if (STRNCASECMP(iobuf, "Authorization:") == 0) {
2403 /* We only allow Basic credentials. 2403 /* We only allow Basic credentials.
2404 * It shows up as "Authorization: Basic <user>:<passwd>" where 2404 * It shows up as "Authorization: Basic <user>:<passwd>" where
2405 * "<user>:<passwd>" is base64 encoded. 2405 * "<user>:<passwd>" is base64 encoded.
2406 */ 2406 */
2407 tptr = skip_whitespace(iobuf + sizeof("Authorization:")-1); 2407 tptr = skip_whitespace(iobuf + sizeof("Authorization:")-1);
2408 if (STRNCASECMP(tptr, "Basic") == 0) { 2408 if (STRNCASECMP(tptr, "Basic") == 0) {
2409 tptr += sizeof("Basic")-1; 2409 tptr += sizeof("Basic")-1;
2410 /* decodeBase64() skips whitespace itself */ 2410 /* decodeBase64() skips whitespace itself */
2411 decodeBase64(tptr); 2411 decodeBase64(tptr);
2412 authorized = check_user_passwd(urlcopy, tptr); 2412 authorized = check_user_passwd(urlcopy, tptr);
2413 continue; 2413 continue;
2414 }
2415 } 2414 }
2415 }
2416#endif 2416#endif
2417#if ENABLE_FEATURE_HTTPD_RANGES 2417#if ENABLE_FEATURE_HTTPD_RANGES
2418 if (STRNCASECMP(iobuf, "Range:") == 0) { 2418 if (STRNCASECMP(iobuf, "Range:") == 0) {
2419 /* We know only bytes=NNN-[MMM] */ 2419 /* We know only bytes=NNN-[MMM] */
2420 char *s = skip_whitespace(iobuf + sizeof("Range:")-1); 2420 char *s = skip_whitespace(iobuf + sizeof("Range:")-1);
2421 if (is_prefixed_with(s, "bytes=")) { 2421 if (is_prefixed_with(s, "bytes=")) {
2422 s += sizeof("bytes=")-1; 2422 s += sizeof("bytes=")-1;
2423 range_start = BB_STRTOOFF(s, &s, 10); 2423 range_start = BB_STRTOOFF(s, &s, 10);
2424 if (s[0] != '-' || range_start < 0) { 2424 if (s[0] != '-' || range_start < 0) {
2425 range_start = -1;
2426 } else if (s[1]) {
2427 range_end = BB_STRTOOFF(s+1, NULL, 10);
2428 if (errno || range_end < range_start)
2425 range_start = -1; 2429 range_start = -1;
2426 } else if (s[1]) {
2427 range_end = BB_STRTOOFF(s+1, NULL, 10);
2428 if (errno || range_end < range_start)
2429 range_start = -1;
2430 }
2431 } 2430 }
2432 continue;
2433 } 2431 }
2432 continue;
2433 }
2434#endif 2434#endif
2435#if ENABLE_FEATURE_HTTPD_GZIP 2435#if ENABLE_FEATURE_HTTPD_GZIP
2436 if (STRNCASECMP(iobuf, "Accept-Encoding:") == 0) { 2436 if (STRNCASECMP(iobuf, "Accept-Encoding:") == 0) {
2437 /* Note: we do not support "gzip;q=0" 2437 /* Note: we do not support "gzip;q=0"
2438 * method of _disabling_ gzip 2438 * method of _disabling_ gzip
2439 * delivery. No one uses that, though */ 2439 * delivery. No one uses that, though */
2440 const char *s = strstr(iobuf, "gzip"); 2440 const char *s = strstr(iobuf, "gzip");
2441 if (s) { 2441 if (s) {
2442 // want more thorough checks? 2442 // want more thorough checks?
2443 //if (s[-1] == ' ' 2443 //if (s[-1] == ' '
2444 // || s[-1] == ',' 2444 // || s[-1] == ','
2445 // || s[-1] == ':' 2445 // || s[-1] == ':'
2446 //) { 2446 //) {
2447 content_gzip = 1; 2447 content_gzip = 1;
2448 //} 2448 //}
2449 }
2450 continue;
2451 } 2449 }
2450 continue;
2451 }
2452#endif 2452#endif
2453#if ENABLE_FEATURE_HTTPD_CGI 2453#if ENABLE_FEATURE_HTTPD_CGI
2454 if (cgi_type != CGI_NONE) { 2454 if (cgi_type != CGI_NONE) {
2455 bool ct = (STRNCASECMP(iobuf, "Content-Type:") == 0); 2455 bool ct = (STRNCASECMP(iobuf, "Content-Type:") == 0);
2456 char *cp; 2456 char *cp;
2457 char *colon = strchr(iobuf, ':'); 2457 char *colon = strchr(iobuf, ':');
2458 2458
2459 if (!colon) 2459 if (!colon)
2460 continue;
2461 cp = iobuf;
2462 while (cp < colon) {
2463 /* a-z => A-Z, not-alnum => _ */
2464 char c = (*cp & ~0x20); /* toupper for A-Za-z, undef for others */
2465 if ((unsigned)(c - 'A') <= ('Z' - 'A')) {
2466 *cp++ = c;
2460 continue; 2467 continue;
2461 cp = iobuf;
2462 while (cp < colon) {
2463 /* a-z => A-Z, not-alnum => _ */
2464 char c = (*cp & ~0x20); /* toupper for A-Za-z, undef for others */
2465 if ((unsigned)(c - 'A') <= ('Z' - 'A')) {
2466 *cp++ = c;
2467 continue;
2468 }
2469 if (!isdigit(*cp))
2470 *cp = '_';
2471 cp++;
2472 } 2468 }
2473 /* "Content-Type:" gets no HTTP_ prefix, all others do */ 2469 if (!isdigit(*cp))
2474 cp = xasprintf(ct ? "HTTP_%.*s=%s" + 5 : "HTTP_%.*s=%s", 2470 *cp = '_';
2475 (int)(colon - iobuf), iobuf, 2471 cp++;
2476 skip_whitespace(colon + 1)
2477 );
2478 putenv(cp);
2479 } 2472 }
2473 /* "Content-Type:" gets no HTTP_ prefix, all others do */
2474 cp = xasprintf(ct ? "HTTP_%.*s=%s" + 5 : "HTTP_%.*s=%s",
2475 (int)(colon - iobuf), iobuf,
2476 skip_whitespace(colon + 1)
2477 );
2478 putenv(cp);
2479 }
2480#endif 2480#endif
2481 } /* while extra header reading */ 2481 } /* while extra header reading */
2482 2482
2483 /* We are done reading headers, disable peer timeout */ 2483 /* We are done reading headers, disable peer timeout */
2484 alarm(0); 2484 alarm(0);