aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebraj Ray <debrajray@Debrajs-MacBook-Air.local>2019-02-27 02:59:15 +0530
committerHanumath Maduri <hmaduri@apache.org>2019-03-01 16:09:31 -0800
commite5859ef2893673644c563d51e5f7af18df92fdd4 (patch)
treed125693c6c5c8c5f9837f5a0bd4cb2bb1f10d23d
parent5323f9dcd92cd1cafec1556afae1c3cea29afae3 (diff)
DRILL-7047: Drill C++ Client crash due to Dangling stack ptr to sasl_callback_t
closes #1661
-rw-r--r--contrib/native/client/src/clientlib/saslAuthenticatorImpl.cpp19
-rw-r--r--contrib/native/client/src/clientlib/saslAuthenticatorImpl.hpp1
2 files changed, 12 insertions, 8 deletions
diff --git a/contrib/native/client/src/clientlib/saslAuthenticatorImpl.cpp b/contrib/native/client/src/clientlib/saslAuthenticatorImpl.cpp
index 6348704c2..0350cfa3f 100644
--- a/contrib/native/client/src/clientlib/saslAuthenticatorImpl.cpp
+++ b/contrib/native/client/src/clientlib/saslAuthenticatorImpl.cpp
@@ -162,18 +162,21 @@ int SaslAuthenticatorImpl::init(const std::vector<std::string>& mechanisms, exec
const std::string saslMechanismToUse = it->second;
- // setup callbacks and parameters
- const sasl_callback_t callbacks[] = {
- { SASL_CB_USER, (sasl_callback_proc_t) &userNameCallback, static_cast<void *>(&m_username) },
- { SASL_CB_AUTHNAME, (sasl_callback_proc_t) &userNameCallback, static_cast<void *>(&m_username) },
- { SASL_CB_PASS, (sasl_callback_proc_t) &passwordCallback, static_cast<void *>(this) },
- { SASL_CB_LIST_END, NULL, NULL }
- };
+ // setup callbacks and parameter
+ sasl_callback_t user = { SASL_CB_USER, (sasl_callback_proc_t) &userNameCallback, static_cast<void *>(&m_username) };
+ sasl_callback_t authname = { SASL_CB_AUTHNAME, (sasl_callback_proc_t)&userNameCallback, static_cast<void *>(&m_username) };
+ sasl_callback_t pass = { SASL_CB_PASS, (sasl_callback_proc_t)&passwordCallback, static_cast<void *>(this) };
+ sasl_callback_t list_end = { SASL_CB_LIST_END, NULL, NULL };
+ m_callbacks.push_back(user);
+ m_callbacks.push_back(authname);
+ m_callbacks.push_back(pass);
+ m_callbacks.push_back(list_end);
+
if (serviceName.empty()) serviceName = DEFAULT_SERVICE_NAME;
// create SASL client
int saslResult = sasl_client_new(serviceName.c_str(), serviceHost.c_str(), NULL /** iplocalport */,
- NULL /** ipremoteport */, callbacks, 0 /** sec flags */, &m_pConnection);
+ NULL /** ipremoteport */, &m_callbacks[0], 0 /** sec flags */, &m_pConnection);
DRILL_MT_LOG(DRILL_LOG(LOG_TRACE) << "SaslAuthenticatorImpl::init: sasl_client_new code: "
<< saslResult << std::endl;)
if (saslResult != SASL_OK) return saslResult;
diff --git a/contrib/native/client/src/clientlib/saslAuthenticatorImpl.hpp b/contrib/native/client/src/clientlib/saslAuthenticatorImpl.hpp
index 56bfcb8f1..a1485000a 100644
--- a/contrib/native/client/src/clientlib/saslAuthenticatorImpl.hpp
+++ b/contrib/native/client/src/clientlib/saslAuthenticatorImpl.hpp
@@ -71,6 +71,7 @@ private:
const DrillUserProperties *const m_pUserProperties;
sasl_conn_t *m_pConnection;
+ std::vector<sasl_callback_t> m_callbacks;
std::string m_username;
sasl_secret_t *m_ppwdSecret;
EncryptionContext *m_pEncryptCtxt;