]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/main: added check for dupfd
authorMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 21 Jul 2015 12:29:54 +0000 (14:29 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 21 Jul 2015 12:29:54 +0000 (14:29 +0200)
fixed CID#125374

daemon/main.c

index 5f4d9fff6c28d2d519a5d0bbdb2385b31dfe7754..f64bf8e2fbaf066a7b57e18735edd732da0de4e2 100644 (file)
@@ -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) {