pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0015-Fix-segfault-in-ipadb_parse_ldap_entry.patch

6ec482
From 480f8a40e9ff8d7f344faac1a9af64972cf2288a Mon Sep 17 00:00:00 2001
6ec482
From: Robbie Harwood <rharwood@redhat.com>
6ec482
Date: Thu, 5 Sep 2019 13:00:27 -0400
6ec482
Subject: [PATCH] Fix segfault in ipadb_parse_ldap_entry()
6ec482
6ec482
lcontext may be NULL here, probably due to a restarted 389ds.  Based on
6ec482
a patch by Rob Crittenden.
6ec482
6ec482
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
6ec482
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
6ec482
---
6ec482
 daemons/ipa-kdb/ipa_kdb_principals.c | 13 +++++++++++++
6ec482
 1 file changed, 13 insertions(+)
6ec482
6ec482
diff --git a/daemons/ipa-kdb/ipa_kdb_principals.c b/daemons/ipa-kdb/ipa_kdb_principals.c
6ec482
index b27612258bbe198154dea5b5d79e551caf9857d1..0fe8e396b9bc011b77b183851389f6c57c70a2c9 100644
6ec482
--- a/daemons/ipa-kdb/ipa_kdb_principals.c
6ec482
+++ b/daemons/ipa-kdb/ipa_kdb_principals.c
6ec482
@@ -21,7 +21,9 @@
6ec482
  */
6ec482
 
6ec482
 #include "ipa_kdb.h"
6ec482
+#include "ipa_krb5.h"
6ec482
 #include <unicase.h>
6ec482
+#include <syslog.h>
6ec482
 
6ec482
 /*
6ec482
  * During TGS request search by ipaKrbPrincipalName (case-insensitive)
6ec482
@@ -554,6 +556,17 @@ static krb5_error_code ipadb_parse_ldap_entry(krb5_context kcontext,
6ec482
         return KRB5_KDB_DBNOTINITED;
6ec482
     }
6ec482
     lcontext = ipactx->lcontext;
6ec482
+    if (!lcontext) {
6ec482
+        krb5_klog_syslog(LOG_INFO,
6ec482
+                         "No LDAP connection in ipadb_parse_ldap_entry(); retrying...\n");
6ec482
+        ret = ipadb_get_connection(ipactx);
6ec482
+        if (ret != 0) {
6ec482
+            krb5_klog_syslog(LOG_ERR,
6ec482
+                             "No LDAP connection on retry in ipadb_parse_ldap_entry()!\n");
6ec482
+            kerr = KRB5_KDB_INTERNAL_ERROR;
6ec482
+            goto done;
6ec482
+        }
6ec482
+    }
6ec482
 
6ec482
     entry->magic = KRB5_KDB_MAGIC_NUMBER;
6ec482
     entry->len = KRB5_KDB_V1_BASE_LENGTH;
6ec482
-- 
6ec482
2.20.1
6ec482