Skip to content

Commit

Permalink
Plugins: CGI: devnull cannot be negative (CID 1124125)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <eduardo@monkey.io>
  • Loading branch information
edsiper committed Jul 23, 2015
1 parent 232b036 commit df43e8b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/cgi/cgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static int do_cgi(const char *const __restrict__ file,
struct mk_plugin *const plugin)
{
int ret;
int devnull;
const int socket = cs->socket;
struct file_info finfo;
struct cgi_request *r = NULL;
Expand Down Expand Up @@ -236,7 +237,12 @@ static int do_cgi(const char *const __restrict__ file,
close(readpipe[1]);

/* Our stderr goes to /dev/null */
const int devnull = open("/dev/null", O_WRONLY);
devnull = open("/dev/null", O_WRONLY);
if (devnull == -1) {
perror("open");
_exit(1);
}

if (dup2(devnull, 2) < 0) {
mk_err("dup2 failed");
_exit(1);
Expand Down

0 comments on commit df43e8b

Please sign in to comment.