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