diff --git a/nselib/smb.lua b/nselib/smb.lua index f08dc56cd..3b51be174 100644 --- a/nselib/smb.lua +++ b/nselib/smb.lua @@ -623,7 +623,7 @@ function start_netbios(host, port, name) return false, "SMB: Failed to close socket: " .. result end pos, result, flags, length = bin.unpack(">CCS", result) - if(length == nil) then + if(result == nil or length == nil) then return false, "SMB: ERROR: Ran off the end of SMB packet; likely due to server truncation [1]" end @@ -1041,7 +1041,7 @@ function negotiate_protocol(smb, overrides) end -- Check if we fell off the packet (if that happened, the last parameter will be nil) - if(mid == nil) then + if(header1 == nil or mid == nil) then return false, "SMB: ERROR: Ran off the end of SMB packet; likely due to server truncation [8]" end @@ -1066,7 +1066,7 @@ function negotiate_protocol(smb, overrides) end pos, smb['security_mode'], smb['max_mpx'], smb['max_vc'], smb['max_buffer'], smb['max_raw_buffer'], smb['session_key'], smb['capabilities'], smb['time'], smb['timezone'], smb['key_length'] = bin.unpack("