b69e47
From e0d5f86c9410bd29c0e4636d3072b24228e60128 Mon Sep 17 00:00:00 2001
b69e47
From: Mark Reynolds <mreynolds@redhat.com>
b69e47
Date: Fri, 5 May 2017 14:58:13 -0400
b69e47
Subject: [PATCH] Ticket 49231 - Fix backport issue
b69e47
b69e47
Description:  The cherry-pick was incorrect, and caused a crash
b69e47
---
b69e47
 ldap/servers/slapd/saslbind.c | 36 ++++++++++++++++++------------------
b69e47
 1 file changed, 18 insertions(+), 18 deletions(-)
b69e47
b69e47
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
b69e47
index 6e544e6..8d23c52 100644
b69e47
--- a/ldap/servers/slapd/saslbind.c
b69e47
+++ b/ldap/servers/slapd/saslbind.c
b69e47
@@ -759,26 +759,26 @@ char **ids_sasl_listmech(Slapi_PBlock *pb)
b69e47
     /* hard-wired mechanisms and slapi plugin registered mechanisms */
b69e47
     sup_ret = slapi_get_supported_saslmechanisms_copy();
b69e47
 
b69e47
-    if (pb->pb_conn == NULL) return ret;
b69e47
+    /* If we have a connection, get the provided list from SASL */
b69e47
+    if (pb->pb_conn != NULL) {
b69e47
+        sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn;
b69e47
 
b69e47
-    sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn;
b69e47
-    if (sasl_conn == NULL) return ret;
b69e47
-
b69e47
-    /* sasl library mechanisms are connection dependent */
b69e47
-    PR_EnterMonitor(pb->pb_conn->c_mutex);
b69e47
-    if (sasl_listmech(sasl_conn, 
b69e47
-                      NULL,     /* username */
b69e47
-                      "", ",", "",
b69e47
-                      &str, NULL, NULL) == SASL_OK) {
b69e47
-        slapi_log_err(SLAPI_LOG_TRACE, "ids_sasl_listmech", "sasl library mechs: %s\n", str);
b69e47
-        /* merge into result set */
b69e47
-        dupstr = slapi_ch_strdup(str);
b69e47
-        others = slapi_str2charray_ext(dupstr, ",", 0 /* don't list duplicate mechanisms */);
b69e47
-        charray_merge(&ret, others, 1);
b69e47
-        charray_free(others);
b69e47
-        slapi_ch_free((void**)&dupstr);
b69e47
+        /* sasl library mechanisms are connection dependent */
b69e47
+        PR_EnterMonitor(pb->pb_conn->c_mutex);
b69e47
+        if (sasl_listmech(sasl_conn,
b69e47
+                          NULL,     /* username */
b69e47
+                          "", ",", "",
b69e47
+                          &str, NULL, NULL) == SASL_OK) {
b69e47
+            slapi_log_err(SLAPI_LOG_TRACE, "ids_sasl_listmech", "sasl library mechs: %s\n", str);
b69e47
+            /* merge into result set */
b69e47
+            dupstr = slapi_ch_strdup(str);
b69e47
+            others = slapi_str2charray_ext(dupstr, ",", 0 /* don't list duplicate mechanisms */);
b69e47
+            charray_merge(&ret, others, 1);
b69e47
+            charray_free(others);
b69e47
+            slapi_ch_free((void**)&dupstr);
b69e47
+        }
b69e47
+        PR_ExitMonitor(pb->pb_conn->c_mutex);
b69e47
     }
b69e47
-    PR_ExitMonitor(pb->pb_conn->c_mutex);
b69e47
 
b69e47
     /* Get the servers "allowed" list */
b69e47
     config_ret = config_get_allowed_sasl_mechs_array();
b69e47
-- 
b69e47
2.9.3
b69e47