Skip to content

Commit

Permalink
lib-auth: Remove request after abort
Browse files Browse the repository at this point in the history
Otherwise the request will still stay in hash table
and get dereferenced when all requests are aborted
causing an attempt to access free'd memory.

Found by Apollon Oikonomopoulos <apoikos@debian.org>

Broken in 1a29ed2
  • Loading branch information
cmouse authored and villesavolainen committed Jan 30, 2018
1 parent a008617 commit 891aa17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib-auth/auth-client-request.c
Expand Up @@ -180,6 +180,8 @@ void auth_client_request_abort(struct auth_client_request **_request)

auth_client_send_cancel(request->conn->client, request->id);
call_callback(request, AUTH_REQUEST_STATUS_ABORT, NULL, NULL);
/* remove the request */
auth_server_connection_remove_request(request->conn, request->id);
pool_unref(&request->pool);
}

Expand Down
7 changes: 7 additions & 0 deletions src/lib-auth/auth-server-connection.c
Expand Up @@ -481,3 +481,10 @@ auth_server_connection_add_request(struct auth_server_connection *conn,
hash_table_insert(conn->requests, POINTER_CAST(id), request);
return id;
}

void auth_server_connection_remove_request(struct auth_server_connection *conn,
unsigned int id)
{
i_assert(conn->handshake_received);
hash_table_remove(conn->requests, POINTER_CAST(id));
}
2 changes: 2 additions & 0 deletions src/lib-auth/auth-server-connection.h
Expand Up @@ -38,4 +38,6 @@ void auth_server_connection_disconnect(struct auth_server_connection *conn,
unsigned int
auth_server_connection_add_request(struct auth_server_connection *conn,
struct auth_client_request *request);
void auth_server_connection_remove_request(struct auth_server_connection *conn,
unsigned int id);
#endif

0 comments on commit 891aa17

Please sign in to comment.