X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuhttpd.git;a=blobdiff_plain;f=cgi.c;fp=cgi.c;h=dc302a9acf32c28d3869ca63176ff418dcd7880c;hp=a2a7e508ecdb37d79c6174fc74b614e7c7b22327;hb=b9178b9357798ae23a5724333cc6572d14f23958;hpb=ae3fe30b6a1d4a45a34b3a896e9a4997c5da500f diff --git a/cgi.c b/cgi.c index a2a7e50..dc302a9 100644 --- a/cgi.c +++ b/cgi.c @@ -52,12 +52,12 @@ static void cgi_main(struct client *cl, struct path_info *pi, char *url) setenv(var->name, var->value, 1); } - chdir(pi->root); - - if (ip) - execl(ip->path, ip->path, pi->phys, NULL); - else - execl(pi->phys, pi->phys, NULL); + if (!chdir(pi->root)) { + if (ip) + execl(ip->path, ip->path, pi->phys, NULL); + else + execl(pi->phys, pi->phys, NULL); + } printf("Status: 500 Internal Server Error\r\n\r\n" "Unable to launch the requested CGI program:\n"