From: Aki Tuomi Date: Wed, 23 Nov 2016 11:16:19 +0000 (+0200) Subject: auth: Fix auth-policy crash when username is NULL X-Git-Tag: 2.3.0.rc1~2542 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3d3faa4f72a676e183f34be960cff13a5a725ae;p=thirdparty%2Fdovecot%2Fcore.git auth: Fix auth-policy crash when username is NULL If SASL request is invalid, or incomplete, and username is left NULL, handle it gracefully by adding just NUL byte in auth policy digest for username. --- diff --git a/src/auth/auth-policy.c b/src/auth/auth-policy.c index 27cedbabd0..26131e791d 100755 --- a/src/auth/auth-policy.c +++ b/src/auth/auth-policy.c @@ -442,7 +442,10 @@ void auth_policy_create_json(struct policy_lookup_ctx *context, context->set->policy_hash_nonce, strlen(context->set->policy_hash_nonce)); /* use +1 to make sure \0 gets included */ - digest->loop(ctx, context->request->user, strlen(context->request->user) + 1); + if (context->request->user == NULL) + digest->loop(ctx, "\0", 1); + else + digest->loop(ctx, context->request->user, strlen(context->request->user) + 1); if (password != NULL) digest->loop(ctx, password, strlen(password)); ptr = (unsigned char*)str_c_modifiable(buffer);