| In the case the dir of the CGI is not accessible, don't run it. - geomyidae - A… | |
| git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| README | |
| LICENSE | |
| --- | |
| commit d3b90fd7b38feae19f7e6192cd15051abfed45d7 | |
| parent 267cfbdc5afa6145475f5017555f05142c3aaefb | |
| Author: Christoph Lohmann <[email protected]> | |
| 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(-) | |
| --- | |
| diff --git a/handlr.c b/handlr.c | |
| @@ -161,8 +161,11 @@ handlecgi(int sock, char *file, char *port, char *base, ch… | |
| 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, c… | |
| 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; |