Blame SOURCES/0001-LDAP-don-t-close-LDAP-socket-twice.patch

688d36
From 895e5b37d14090541480cebcb297846cbd3662ce Mon Sep 17 00:00:00 2001
688d36
From: Sumit Bose <sbose@redhat.com>
688d36
Date: Fri, 25 Nov 2016 17:35:11 +0100
688d36
Subject: [PATCH] LDAP: don't close LDAP socket twice
688d36
688d36
ldap_destroy() will call close() on the LDAP socket so with an explicit
688d36
close() before the file descriptor will be closed twice. Even worse,
688d36
since the file descriptor can be reused after the explicit call of
688d36
close() by any other thread the close() called from ldap_destroy() might
688d36
close a file descriptor used by a different thread as seen e.g. in
688d36
https://bugzilla.redhat.com/show_bug.cgi?id=1398522.
688d36
688d36
Additionally the patch makes sure that the closed connection cannot be
688d36
used again.
688d36
688d36
https://bugzilla.redhat.com/show_bug.cgi?id=1398522
688d36
---
688d36
 service/realm-ldap.c | 5 +++--
688d36
 1 file changed, 3 insertions(+), 2 deletions(-)
688d36
688d36
diff --git a/service/realm-ldap.c b/service/realm-ldap.c
688d36
index 061ed61..59817fb 100644
688d36
--- a/service/realm-ldap.c
688d36
+++ b/service/realm-ldap.c
688d36
@@ -159,10 +159,11 @@ ldap_source_finalize (GSource *source)
688d36
 {
688d36
 	LdapSource *ls = (LdapSource *)source;
688d36
 
688d36
-	/* Yeah, this is pretty rough, but we don't want blocking here */
688d36
-	close (ls->sock);
688d36
 	ldap_destroy (ls->ldap);
688d36
 
688d36
+	ls->sock = -1;
688d36
+	ls->ldap = NULL;
688d36
+
688d36
 	if (ls->cancellable) {
688d36
 		g_cancellable_release_fd (ls->cancellable);
688d36
 		g_object_unref (ls->cancellable);
688d36
-- 
688d36
2.9.3
688d36