1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-04 13:49:03 +00:00

Fix a bug in creds.lua, comparing creds without users

When creds.lua is used without usernames (like in snmp-brute.nse), the
credentials could not be sorted because they are sorted first by
username, which is nil and cannot be compared. Now the script first
checks that both values are non-nil (and true) before comparing them.
This commit is contained in:
dmiller
2015-05-26 03:40:09 +00:00
parent 0f602cbd38
commit 63ad40fb74

View File

@@ -266,11 +266,11 @@ Account = {
--
-- Lexicographic comparison by user, pass, and state
__lt = function (a, b)
if a.user >= b.user then
if a.user and b.user and a.user >= b.user then
return false
elseif a.pass >= b.pass then
elseif a.pass and b.pass and a.pass >= b.pass then
return false
elseif a.state >= b.state then
elseif a.state and b.state and a.state >= b.state then
return false
end
return true