s3:winbind: Check if we have an open file descriptor
authorAndreas Schneider <asn@samba.org>
Wed, 16 May 2018 12:06:36 +0000 (14:06 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 17 May 2018 15:30:08 +0000 (17:30 +0200)
Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/winbindd/winbindd_cm.c

index 52b4c2c689fc480d7a5c848c6f9e55c69c861c6a..95612034d2f939cb29413db91732e605f1750f6d 100644 (file)
@@ -1983,7 +1983,10 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
                        &new_conn->cli, &retry);
                if (!NT_STATUS_IS_OK(result)) {
                        /* Don't leak the smb connection socket */
-                       close(fd);
+                       if (fd != -1) {
+                               close(fd);
+                               fd = -1;
+                       }
                }
 
                if (!retry)