aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-12-18 03:22:36 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-12-18 03:22:36 +0100
commitf85bd1a7a7e712c4dd2dfd86daa9ab01a708b7b4 (patch)
tree140546e7347ada375c1a1c1dcbc08770e8e17e36
parentee0f444f11504e47fc0f3ab6bc2bf95defb6e6ae (diff)
downloadbusybox-w32-f85bd1a7a7e712c4dd2dfd86daa9ab01a708b7b4.tar.gz
busybox-w32-f85bd1a7a7e712c4dd2dfd86daa9ab01a708b7b4.tar.bz2
busybox-w32-f85bd1a7a7e712c4dd2dfd86daa9ab01a708b7b4.zip
httpd: remove redundant NULL assignment and save one strrchr. -8 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/httpd.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index f52785bf4..cda7cc7af 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1284,7 +1284,7 @@ static void send_cgi_and_exit(
1284{ 1284{
1285 struct fd_pair fromCgi; /* CGI -> httpd pipe */ 1285 struct fd_pair fromCgi; /* CGI -> httpd pipe */
1286 struct fd_pair toCgi; /* httpd -> CGI pipe */ 1286 struct fd_pair toCgi; /* httpd -> CGI pipe */
1287 char *script; 1287 char *script, *last_slash;
1288 int pid; 1288 int pid;
1289 1289
1290 /* Make a copy. NB: caller guarantees: 1290 /* Make a copy. NB: caller guarantees:
@@ -1298,15 +1298,18 @@ static void send_cgi_and_exit(
1298 */ 1298 */
1299 1299
1300 /* Check for [dirs/]script.cgi/PATH_INFO */ 1300 /* Check for [dirs/]script.cgi/PATH_INFO */
1301 script = (char*)url; 1301 last_slash = script = (char*)url;
1302 while ((script = strchr(script + 1, '/')) != NULL) { 1302 while ((script = strchr(script + 1, '/')) != NULL) {
1303 int dir;
1303 *script = '\0'; 1304 *script = '\0';
1304 if (!is_directory(url + 1, 1, NULL)) { 1305 dir = is_directory(url + 1, /*followlinks:*/ 1, NULL);
1306 *script = '/';
1307 if (!dir) {
1305 /* not directory, found script.cgi/PATH_INFO */ 1308 /* not directory, found script.cgi/PATH_INFO */
1306 *script = '/';
1307 break; 1309 break;
1308 } 1310 }
1309 *script = '/'; /* is directory, find next '/' */ 1311 /* is directory, find next '/' */
1312 last_slash = script;
1310 } 1313 }
1311 setenv1("PATH_INFO", script); /* set to /PATH_INFO or "" */ 1314 setenv1("PATH_INFO", script); /* set to /PATH_INFO or "" */
1312 setenv1("REQUEST_METHOD", request); 1315 setenv1("REQUEST_METHOD", request);
@@ -1387,7 +1390,7 @@ static void send_cgi_and_exit(
1387 log_and_exit(); 1390 log_and_exit();
1388 } 1391 }
1389 1392
1390 if (!pid) { 1393 if (pid == 0) {
1391 /* Child process */ 1394 /* Child process */
1392 char *argv[3]; 1395 char *argv[3];
1393 1396
@@ -1403,7 +1406,7 @@ static void send_cgi_and_exit(
1403 /* dup2(1, 2); */ 1406 /* dup2(1, 2); */
1404 1407
1405 /* Chdiring to script's dir */ 1408 /* Chdiring to script's dir */
1406 script = strrchr(url, '/'); 1409 script = last_slash;
1407 if (script != url) { /* paranoia */ 1410 if (script != url) { /* paranoia */
1408 *script = '\0'; 1411 *script = '\0';
1409 if (chdir(url + 1) != 0) { 1412 if (chdir(url + 1) != 0) {
@@ -1992,7 +1995,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
1992 /* NB: urlcopy ptr is never changed after this */ 1995 /* NB: urlcopy ptr is never changed after this */
1993 1996
1994 /* Extract url args if present */ 1997 /* Extract url args if present */
1995 g_query = NULL; 1998 /* g_query = NULL; - already is */
1996 tptr = strchr(urlcopy, '?'); 1999 tptr = strchr(urlcopy, '?');
1997 if (tptr) { 2000 if (tptr) {
1998 *tptr++ = '\0'; 2001 *tptr++ = '\0';