geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit d3b90fd7b38feae19f7e6192cd15051abfed45d7
parent 267cfbdc5afa6145475f5017555f05142c3aaefb
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:
handlr.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

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;