Skip to content

Commit

Permalink
FIX: Prevent calling sasl_server_step() before sasl_server_start()
Browse files Browse the repository at this point in the history
  • Loading branch information
namsic committed Nov 11, 2024
1 parent bf52896 commit 0b11d38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ conn *conn_new(const int sfd, STATE_FUNC init_state,
c->next = NULL;
c->conn_prev = NULL;
c->conn_next = NULL;
c->sasl_started = false;
c->authenticated = false;

c->write_and_go = init_state;
Expand Down Expand Up @@ -4267,8 +4268,17 @@ static void process_bin_complete_sasl_auth(conn *c)
case PROTOCOL_BINARY_CMD_SASL_AUTH:
result = sasl_server_start(c->sasl_conn, mech, challenge, vlen,
&out, &outlen);
c->sasl_started = (result == SASL_OK || result == SASL_CONTINUE);
break;
case PROTOCOL_BINARY_CMD_SASL_STEP:
if (!c->sasl_started) {
if (settings.verbose) {
mc_logger->log(EXTENSION_LOG_WARNING, c,
"%d: SASL_STEP called but sasl_server_start "
"not called for this connection!\n", c->sfd);
}
break;
}
result = sasl_server_step(c->sasl_conn, challenge, vlen,
&out, &outlen);
break;
Expand Down
1 change: 1 addition & 0 deletions memcached.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ struct conn {
int sfd;
short nevents;
sasl_conn_t *sasl_conn;
bool sasl_started;
bool authenticated;
STATE_FUNC state;
enum bin_substates substate;
Expand Down

0 comments on commit 0b11d38

Please sign in to comment.