From: Marek VavruĊĦa Date: Tue, 21 Jul 2015 12:29:54 +0000 (+0200) Subject: daemon/main: added check for dupfd X-Git-Tag: v1.0.0-beta1~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=693f1c9f59a15f0e8cffd8f2c9a1d17c05f49ac9;p=thirdparty%2Fknot-resolver.git daemon/main: added check for dupfd fixed CID#125374 --- diff --git a/daemon/main.c b/daemon/main.c index 5f4d9fff6..f64bf8e2f 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -49,7 +49,10 @@ static void tty_read(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) uv_close((uv_handle_t *)stream, (uv_close_cb) free); return; } - out = outerr = fdopen(dup(stream_fd), "w"); + uv_os_fd_t dup_fd = dup(stream_fd); + if (dup_fd >= 0) { + out = outerr = fdopen(dup(stream_fd), "w"); + } } /* Execute */ if (stream && buf && nread > 0) {