In the case the dir of the CGI is not accessible, don't run it. - geomyidae - A small C-based gopherd. HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit d3b90fd7b38feae19f7e6192cd15051abfed45d7 DIR parent 267cfbdc5afa6145475f5017555f05142c3aaefb HTML Author: Christoph Lohmann <20h@r-36.net> Date: Sat, 24 Oct 2015 19:15:50 +0200 In the case the dir of the CGI is not accessible, don't run it. Diffstat: M handlr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- DIR diff --git a/handlr.c b/handlr.c @@ -161,8 +161,11 @@ handlecgi(int sock, char *file, char *port, char *base, char *args, dup2(sock, 2); switch(fork()) { case 0: - if (path != nil) - chdir(path); + if (path != nil) { + if (chdir(path) < 0) + break; + } + execl(file, p, sear, args, ohost, port, (char *)nil); case -1: break; @@ -211,8 +214,11 @@ handledcgi(int sock, char *file, char *port, char *base, char *args, case 0: dup2(outpipe[1], 1); close(outpipe[0]); - if (path != nil) - chdir(path); + if (path != nil) { + if (chdir(path) < 0) + break; + } + execl(file, p, sear, args, ohost, port, (char *)nil); case -1: break;