From b9178b9357798ae23a5724333cc6572d14f23958 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 28 Mar 2015 17:25:40 +0100 Subject: properly handle return codes Signed-off-by: John Crispin --- cgi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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" -- cgit v1.2.3