[PATCH] Fix possible close of invalid fd if call to socket() returns -1.

Tim Potter tpot at samba.org
Sun Feb 17 23:43:46 GMT 2008


---
 source/lib/util_sock.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c
index 71d48d6..e040f46 100644
--- a/source/lib/util_sock.c
+++ b/source/lib/util_sock.c
@@ -1933,7 +1933,8 @@ int create_pipe_sock(const char *socket_dir,
 
 out_close:
 	SAFE_FREE(path);
-	close(sock);
+	if (sock != -1)
+		close(sock);
 
 out_umask:
 	umask(old_umask);
-- 
1.5.2.5



More information about the samba-technical mailing list