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

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