In bind_port(), check if the socket is valid before marking it CLOSEEXEC
authorFabian Keil <fk@fabiankeil.de>
Sat, 18 Oct 2014 11:27:43 +0000 (11:27 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sat, 18 Oct 2014 11:27:43 +0000 (11:27 +0000)
jbsockets.c

index 13a6a0c..dec4204 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.127 2014/06/03 10:27:56 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.128 2014/10/18 11:24:53 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -909,10 +909,6 @@ int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
    fd = socket(AF_INET, SOCK_STREAM, 0);
 #endif /* def HAVE_RFC2553 */
 
-#ifdef FEATURE_EXTERNAL_FILTERS
-   mark_socket_for_close_on_execute(fd);
-#endif
-
 #ifdef _WIN32
    if (fd == JB_INVALID_SOCKET)
 #else
@@ -926,6 +922,10 @@ int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
 #endif
    }
 
+#ifdef FEATURE_EXTERNAL_FILTERS
+   mark_socket_for_close_on_execute(fd);
+#endif
+
 #ifndef _WIN32
    /*
     * This is not needed for Win32 - in fact, it stops