From f66e0fcfb93fa68e735882ed261eeed98ef30be1 Mon Sep 17 00:00:00 2001 From: henri Date: Thu, 12 Jul 2012 17:17:46 +0000 Subject: [PATCH] Ensure that inheritable_socket() returned a valid FD before passing it to Setsockopt(). --- ncat/util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ncat/util.c b/ncat/util.c index 2aaaf847c..0e0f64637 100644 --- a/ncat/util.c +++ b/ncat/util.c @@ -382,6 +382,8 @@ int do_listen(int type, int proto, const union sockaddr_u *srcaddr_u) ncat_exec_win.c, for --exec and --sh-exec. inheritable_socket is from nbase. */ sock = inheritable_socket(srcaddr_u->storage.ss_family, type, proto); + if (sock < 0) + bye("socket: %s", socket_strerror(socket_errno())); Setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &option_on, sizeof(int));