s3-rpc_server: Make sure that fd is really closed on error.
authorAndreas Schneider <asn@samba.org>
Wed, 20 Feb 2013 09:52:37 +0000 (10:52 +0100)
committerAlexander Bokovoy <ab@samba.org>
Fri, 22 Feb 2013 15:36:14 +0000 (16:36 +0100)
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source3/rpc_server/rpc_sock_helper.c

index 198df903ad422aae34949f3c27900cd6c1d9b5a8..dc88f25a9000e4d147e5d15492a8531b206973c6 100644 (file)
@@ -63,6 +63,9 @@ NTSTATUS rpc_create_tcpip_sockets(const struct ndr_interface_table *iface,
                        fd = create_tcpip_socket(ifss, &p);
                        if (fd < 0 || p == 0) {
                                status = NT_STATUS_UNSUCCESSFUL;
+                               if (fd != -1) {
+                                       close(fd);
+                               }
                                goto done;
                        }
                        listen_fd[*listen_fd_size] = fd;
@@ -124,6 +127,9 @@ NTSTATUS rpc_create_tcpip_sockets(const struct ndr_interface_table *iface,
                        fd = create_tcpip_socket(&ss, &p);
                        if (fd < 0 || p == 0) {
                                status = NT_STATUS_UNSUCCESSFUL;
+                               if (fd != -1) {
+                                       close(fd);
+                               }
                                goto done;
                        }
                        listen_fd[*listen_fd_size] = fd;