IMPALA-2645: Set mechUsing only on success Better to check success status from sasl_client_start() before using returned structure with auth mechanism. According to the API documentation, its value is guaranteed only after success (no error, or SASL_CONTINUE).
Change-Id: I71e5bb754866003e2a282ce3eeb8d4e6eac0573d Reviewed-on: http://gerrit.cloudera.org:8080/2687 Tested-by: Internal Jenkins Reviewed-by: Henry Robinson <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/7dd4998b Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/7dd4998b Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/7dd4998b Branch: refs/heads/master Commit: 7dd4998b4fc142425080fa1cce07dcf36df24c1d Parents: 5703f4e Author: FrantiÅ¡ek DvoÅák <[email protected]> Authored: Thu Mar 31 23:43:37 2016 +0200 Committer: Henry Robinson <[email protected]> Committed: Tue Apr 5 22:26:16 2016 +0000 ---------------------------------------------------------------------- be/src/transport/TSasl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/7dd4998b/be/src/transport/TSasl.cpp ---------------------------------------------------------------------- diff --git a/be/src/transport/TSasl.cpp b/be/src/transport/TSasl.cpp index 31e1e1a..3108dff 100644 --- a/be/src/transport/TSasl.cpp +++ b/be/src/transport/TSasl.cpp @@ -148,7 +148,9 @@ uint8_t* TSaslClient::evaluateChallengeOrResponse( &outlen, /* filled in on success */ (const char**)&mechUsing); clientStarted = true; - chosenMech = mechUsing; + if (result == SASL_OK || result == SASL_CONTINUE) { + chosenMech = mechUsing; + } } else { if (len > 0) { result=sasl_client_step(conn, /* our context */
