Fix crash when unregistering unauthenticated connection

This commit is contained in:
Tim Kächele 2024-02-26 19:41:25 +01:00
parent 98ab862d5e
commit fd00a29667
2 changed files with 11 additions and 1 deletions

View File

@ -58,7 +58,7 @@ module Rex
@connection_message_counter.delete(connection_id) @connection_message_counter.delete(connection_id)
@user_connection_associations[ @user_connection_associations[
@connection_user_associations[connection_id] @connection_user_associations[connection_id]
].delete(connection_id) ]&.delete(connection_id)
@connection_user_associations.delete(connection_id) @connection_user_associations.delete(connection_id)
end end

View File

@ -101,4 +101,14 @@ RSpec.describe Rex::Server::MessageBroker do
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
end end
describe "#unregister" do
context 'when connection was never associated with a user' do
it 'does not crash' do
expect do
instance.unregister(connection_id_a)
end.not_to raise_error
end
end
end
end end