From 918c24a5400acb15003ed202e15b11942a4b7a42 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 10 Mar 2018 03:09:33 +0000 Subject: [PATCH] Don't crash a thread if Driver.connect didn't return a brute.Error --- nselib/brute.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/nselib/brute.lua b/nselib/brute.lua index d0dd9e26c..2a9e012cc 100644 --- a/nselib/brute.lua +++ b/nselib/brute.lua @@ -703,14 +703,22 @@ Engine = { -- Temporary workaround. Did not connect sucessfully -- due to stressed server - if not status and response:isReduce() then + if not status then + -- We have to first check whether the response is a brute.Error + -- since many times the connect method returns a string error instead, + -- which could crash this thread in several places + if response and not response.isReduce then + -- Create a new Error + response = Error:new("Connect error: " .. response) + response:setRetry(true) + end + if response:isReduce() then local ret_creds = {} ret_creds.connect_phase = true return false, response, ret_creds - end - + end + else -- Did we successfully connect? - if status then if not username and not password then repeat if #self.retry_accounts > 0 then