Skip to content

Commit

Permalink
Account for errors when generating IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Mar 29, 2024
1 parent 3dceda0 commit e6a8211
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ruby_smb/server/server_client/session_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ def do_logoff_andx_smb1(request, session)
end

def do_session_setup_smb2(request, session)
@smb2_related_operations_state.delete(:session_id)

session_id = request.smb2_header.session_id
if session_id == 0
session_id = rand(1..0xfffffffe)
session = @session_table[session_id] = Session.new(session_id)
session = Session.new(session_id)
else
session = @session_table[session_id]
if session.nil?
Expand Down Expand Up @@ -92,6 +94,8 @@ def do_session_setup_smb2(request, session)
update_preauth_hash(response)
end


@session_table[session_id] = session
@smb2_related_operations_state[:session_id] = session_id

response
Expand Down
2 changes: 2 additions & 0 deletions lib/ruby_smb/server/server_client/tree_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def do_tree_disconnect_smb1(request, session)
end

def do_tree_connect_smb2(request, session)
@smb2_related_operations_state.delete(:tree_id)

response = RubySMB::SMB2::Packet::TreeConnectResponse.new
response.smb2_header.credits = 1
if session.tree_connect_table.length >= MAX_TREE_CONNECTIONS
Expand Down

0 comments on commit e6a8211

Please sign in to comment.