From: Aki Tuomi Date: Mon, 5 Jun 2017 09:14:57 +0000 (+0300) Subject: auth: Access always first entry when flushing failures X-Git-Tag: 2.3.0.rc1~1519 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b20202007c06fa77da44d00fbac7f029cb6d8f86;p=thirdparty%2Fdovecot%2Fcore.git auth: Access always first entry when flushing failures The code is deleting the first item after accessing it, and then moving forward. It will eventually go beyond the array and get NULL ptr and fail. Instead we need to always get the first item, since the array deletion is moving the queued items forward. Broken by e18b4e41 --- diff --git a/src/auth/auth-request-handler.c b/src/auth/auth-request-handler.c index 2c7468969d..543c4bf28e 100644 --- a/src/auth/auth-request-handler.c +++ b/src/auth/auth-request-handler.c @@ -865,9 +865,10 @@ void auth_request_handler_flush_failures(bool flush_all) /* flush the requests */ for (i = 0; i < count; i++) { - auth_request = auth_requests[aqueue_idx(auth_failures, i)]; + auth_request = auth_requests[aqueue_idx(auth_failures, 0)]; aqueue_delete_tail(auth_failures); + i_assert(auth_request != NULL); i_assert(auth_request->state == AUTH_REQUEST_STATE_FINISHED); auth_request_handler_reply(auth_request, AUTH_CLIENT_RESULT_FAILURE,