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