From 63ad40fb7416bf8f81d92fe61903b8ed200fa451 Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 26 May 2015 03:40:09 +0000 Subject: [PATCH] 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. --- nselib/creds.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nselib/creds.lua b/nselib/creds.lua index 722a2e72d..4c6783352 100644 --- a/nselib/creds.lua +++ b/nselib/creds.lua @@ -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