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