From 0699edbe0509e5c5ab0e596fbd75cd07b35c5e3b Mon Sep 17 00:00:00 2001 From: tomsellers Date: Mon, 11 Apr 2016 18:04:53 +0000 Subject: [PATCH] NSE: ldap-rootdse.nse improve error handling --- scripts/ldap-rootdse.nse | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/ldap-rootdse.nse b/scripts/ldap-rootdse.nse index f7255f122..9a5ac09bb 100644 --- a/scripts/ldap-rootdse.nse +++ b/scripts/ldap-rootdse.nse @@ -135,6 +135,11 @@ function action(host,port) req = { baseObject = "", scope = ldap.SCOPE.base, derefPolicy = ldap.DEREFPOLICY.default } status, searchResEntries = ldap.searchRequest( socket, req ) + if not status then + socket:close() + return stdnse.format_output(false, searchResEntries) + end + -- Check if we were served all the results or not? if not ldap.extractAttribute( searchResEntries, "namingContexts" ) and not ldap.extractAttribute( searchResEntries, "supportedLDAPVersion" ) then @@ -159,7 +164,7 @@ function action(host,port) status, searchResEntries = ldap.udpSearchRequest( host, port, req ) end - if not status or not searchResEntries then return end + if not status or not searchResEntries then return stdnse.format_output(false, searchResEntries) end result = ldap.searchResultToTable( searchResEntries ) -- if taken a way and ldap returns a single result, it ain't shown....