conn: don't crash when user sets password to NULL
Make it possible to reset password to NULL. It is not required for ANONYMOUS authentication. Also, report an error and disconnect if password is not set and libstrophe should try authentication mechanisms other than ANONYMOUS.
This commit is contained in:
@@ -667,6 +667,10 @@ static void _auth(xmpp_conn_t *const conn)
|
||||
xmpp_error(conn->ctx, "auth",
|
||||
"No node in JID, and SASL ANONYMOUS unsupported.");
|
||||
xmpp_disconnect(conn);
|
||||
} else if (conn->pass == NULL) {
|
||||
xmpp_error(conn->ctx, "auth",
|
||||
"Password hasn't been set, and SASL ANONYMOUS unsupported.");
|
||||
xmpp_disconnect(conn);
|
||||
} else if (conn->sasl_support & SASL_MASK_SCRAM) {
|
||||
scram_ctx = xmpp_alloc(conn->ctx, sizeof(*scram_ctx));
|
||||
if (conn->sasl_support & SASL_MASK_SCRAMSHA512)
|
||||
|
||||
@@ -420,7 +420,7 @@ void xmpp_conn_set_pass(xmpp_conn_t *const conn, const char *const pass)
|
||||
{
|
||||
if (conn->pass)
|
||||
xmpp_free(conn->ctx, conn->pass);
|
||||
conn->pass = xmpp_strdup(conn->ctx, pass);
|
||||
conn->pass = pass ? xmpp_strdup(conn->ctx, pass) : NULL;
|
||||
}
|
||||
|
||||
/** Get the strophe context that the connection is associated with.
|
||||
|
||||
Reference in New Issue
Block a user