From 86da86007c7677e6e9f06d2642f10c853a5ccc1b Mon Sep 17 00:00:00 2001 From: jah Date: Tue, 23 Aug 2016 22:39:29 +0000 Subject: [PATCH] Fix "bad argument #1 to 'match' (string expected, got nil)" in hostrule by returning early when nfs-ls and nfs-statfs do not have the required version numbers for the nfs and mountd ports. --- scripts/nfs-ls.nse | 9 +++++++-- scripts/nfs-statfs.nse | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/nfs-ls.nse b/scripts/nfs-ls.nse index 0dec40f6a..1e102b173 100644 --- a/scripts/nfs-ls.nse +++ b/scripts/nfs-ls.nse @@ -167,7 +167,13 @@ hostrule = function(host) end if mountport and nfsport then break end end - if nfsport == nil then return false end + -- Run when nfs and mount ports were scanned and their versions numbers known + if not (nfsport and (host.registry.nfs.nfsver or nfsport.version.version)) then + return false + end + if not (mountport and (host.registry.nfs.mountver or mountport.version.version)) then + return false + end if host.registry.nfs.nfsver == nil then local low, high = string.match(nfsport.version.version, "(%d)%-(%d)") if high == nil then @@ -185,7 +191,6 @@ hostrule = function(host) end end end - if mountport == nil then return false end if host.registry.nfs.mountver == nil then local low, high = string.match(mountport.version.version, "(%d)%-(%d)") if high == nil then diff --git a/scripts/nfs-statfs.nse b/scripts/nfs-statfs.nse index 8c7ffd6b6..a4477f966 100644 --- a/scripts/nfs-statfs.nse +++ b/scripts/nfs-statfs.nse @@ -68,7 +68,13 @@ hostrule = function(host) end if mountport and nfsport then break end end - if nfsport == nil then return false end + -- Run when nfs and mount ports were scanned and their versions numbers known + if not (nfsport and (host.registry.nfs.nfsver or nfsport.version.version)) then + return false + end + if not (mountport and (host.registry.nfs.mountver or mountport.version.version)) then + return false + end if host.registry.nfs.nfsver == nil then local low, high = string.match(nfsport.version.version, "(%d)%-(%d)") if high == nil then @@ -86,7 +92,6 @@ hostrule = function(host) end end end - if mountport == nil then return false end if host.registry.nfs.mountver == nil then local low, high = string.match(mountport.version.version, "(%d)%-(%d)") if high == nil then