Unverified Commit e0d419f0 authored by Jia Zhouyang's avatar Jia Zhouyang Committed by GitHub

Add error handling for chdir

When chdir fails, print error message and exit.
parent a58f37c9
......@@ -426,7 +426,10 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
}
#ifdef HAVE_CHDIR /* ifndef __EMX__ ? */
chdir(cgi_dir);
if (chdir(cgi_dir) == -1) {
fprintf(stderr, "failed to chdir to %s: %s\n", cgi_dir, strerror(errno));
exit(1);
}
#endif
execl(file, cgi_basename, NULL);
fprintf(stderr, "execl(\"%s\", \"%s\", NULL): %s\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment