mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 20:29:03 +00:00
fixed a bug in a loop where the script would wait for a condition that was
supposed to be signalled by other threads which were no longer running.
This commit is contained in:
@@ -694,10 +694,12 @@ Helper = {
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for t in pairs(threads) do
|
||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until( next(threads) == nil )
|
||||
|
||||
for name, answer in pairs(answers) do
|
||||
|
||||
@@ -192,10 +192,12 @@ action = function()
|
||||
|
||||
-- wait until all threads are done
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
local response = {}
|
||||
|
||||
@@ -104,12 +104,14 @@ action = function(host, port)
|
||||
|
||||
-- wait until the probes are all done
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then
|
||||
threads[thread] = nil
|
||||
end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
return stdnse.format_output(true, result)
|
||||
|
||||
@@ -251,10 +251,12 @@ action = function()
|
||||
local condvar = nmap.condvar(astab)
|
||||
-- Wait for the listening threads to finish
|
||||
repeat
|
||||
condvar("wait")
|
||||
for thread in pairs(lthreads) do
|
||||
if coroutine.status(thread) == "dead" then lthreads[thread] = nil end
|
||||
end
|
||||
if ( next(lthreads) ) then
|
||||
condvar("wait")
|
||||
end
|
||||
until next(lthreads) == nil;
|
||||
|
||||
if #astab > 0 then
|
||||
|
||||
@@ -309,10 +309,12 @@ action = function(host, port)
|
||||
local condvar = nmap.condvar(responses)
|
||||
-- Wait for the listening threads to finish
|
||||
repeat
|
||||
condvar("wait")
|
||||
for thread in pairs(lthreads) do
|
||||
if coroutine.status(thread) == "dead" then lthreads[thread] = nil end
|
||||
end
|
||||
if ( next(lthreads) ) then
|
||||
condvar("wait")
|
||||
end
|
||||
until next(lthreads) == nil;
|
||||
|
||||
-- Output useful info from the responses
|
||||
|
||||
@@ -265,12 +265,14 @@ action = function()
|
||||
|
||||
-- wait for all threads to finish sniffing
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then
|
||||
threads[thread] = nil
|
||||
end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
local out_outer = {}
|
||||
|
||||
@@ -113,12 +113,14 @@ action = function()
|
||||
|
||||
-- wait until the probes are all done
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then
|
||||
threads[thread] = nil
|
||||
end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
table.sort(responses, function(a,b) return a.name < b.name end)
|
||||
|
||||
@@ -255,10 +255,12 @@ action = function()
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
-- generate output
|
||||
|
||||
@@ -86,11 +86,13 @@ action = function()
|
||||
local done
|
||||
-- wait for all threads to finish
|
||||
while( not(done) ) do
|
||||
condvar("wait")
|
||||
done = true
|
||||
for thread in pairs(threads) do
|
||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||
end
|
||||
if ( not(done) ) then
|
||||
condvar("wait")
|
||||
end
|
||||
end
|
||||
|
||||
if ( results ) then
|
||||
|
||||
@@ -235,11 +235,13 @@ action = function(host)
|
||||
local done
|
||||
-- wait for all threads to finish
|
||||
while( not(done) ) do
|
||||
condvar("wait")
|
||||
done = true
|
||||
for thread in pairs(threads) do
|
||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||
end
|
||||
if ( not(done) ) then
|
||||
condvar("wait")
|
||||
end
|
||||
end
|
||||
|
||||
if(dosrv) then
|
||||
@@ -257,11 +259,13 @@ action = function(host)
|
||||
local done
|
||||
-- wait for all threads to finish
|
||||
while( not(done) ) do
|
||||
condvar("wait")
|
||||
done = true
|
||||
for thread in pairs(threads) do
|
||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||
end
|
||||
if ( not(done) ) then
|
||||
condvar("wait")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -80,10 +80,12 @@ action = function()
|
||||
|
||||
local condvar = nmap.condvar(result)
|
||||
repeat
|
||||
condvar "wait"
|
||||
for t in pairs(threads) do
|
||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until( next(threads) == nil )
|
||||
|
||||
if ( 0 == #result ) then
|
||||
|
||||
@@ -167,10 +167,12 @@ action = function(host)
|
||||
|
||||
local condvar = nmap.condvar(result)
|
||||
repeat
|
||||
condvar "wait"
|
||||
for t in pairs(threads) do
|
||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until( next(threads) == nil )
|
||||
|
||||
table.sort(result, function(a,b) return a.name < b.name end)
|
||||
|
||||
@@ -239,7 +239,6 @@ local function worker_scheduler(host, port)
|
||||
while not DOSed and not StopAll do
|
||||
-- keep creating new threads, in case we want to run the attack indefinitely
|
||||
repeat
|
||||
condvar("wait")
|
||||
if StopAll then
|
||||
return
|
||||
end
|
||||
@@ -252,6 +251,9 @@ local function worker_scheduler(host, port)
|
||||
stdnse.print_debug(SCRIPT_NAME .. " [SCHEDULER]: starting new thread")
|
||||
local co = stdnse.new_thread(do_half_http, host, port, obj)
|
||||
Threads[co] = true
|
||||
if ( next(Threads) ) then
|
||||
condvar("wait")
|
||||
end
|
||||
until next(Threads) == nil;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -389,10 +389,12 @@ action = function( host, port )
|
||||
|
||||
-- wait for all threads to finish up
|
||||
repeat
|
||||
condvar "wait"
|
||||
for t in pairs(threads) do
|
||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until( next(threads) == nil )
|
||||
|
||||
if ( #result > 0 ) then
|
||||
|
||||
@@ -308,10 +308,12 @@ action = function()
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
-- generate output
|
||||
|
||||
@@ -237,12 +237,14 @@ action = function(host, port)
|
||||
|
||||
local condvar = nmap.condvar(result)
|
||||
repeat
|
||||
condvar "wait";
|
||||
for thread in pairs(lthreads) do
|
||||
if coroutine.status(thread) == "dead" then
|
||||
lthreads[thread] = nil
|
||||
end
|
||||
end
|
||||
if ( next(lthreads) ) then
|
||||
condvar "wait";
|
||||
end
|
||||
until next(lthreads) == nil;
|
||||
|
||||
-- Check the result and set the port version.
|
||||
|
||||
@@ -125,10 +125,12 @@ action = function(host, port)
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for t in pairs(threads) do
|
||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until( next(threads) == nil )
|
||||
|
||||
-- urls that could not be retrieved due to low level errors, such as
|
||||
|
||||
@@ -169,10 +169,12 @@ action = function()
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
return format_output(results)
|
||||
|
||||
@@ -201,10 +201,12 @@ action = function()
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
return format_output(results)
|
||||
|
||||
@@ -166,10 +166,12 @@ action = function()
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
return format_output(results)
|
||||
|
||||
@@ -251,10 +251,12 @@ action = function()
|
||||
end
|
||||
|
||||
repeat
|
||||
condvar "wait"
|
||||
for thread in pairs(threads) do
|
||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||
end
|
||||
if ( next(threads) ) then
|
||||
condvar "wait"
|
||||
end
|
||||
until next(threads) == nil
|
||||
|
||||
return format_output(results)
|
||||
|
||||
@@ -75,11 +75,13 @@ action = function(host, port)
|
||||
local done
|
||||
-- wait for all threads to finish
|
||||
while( not(done) ) do
|
||||
condvar("wait")
|
||||
done = true
|
||||
for thread in pairs(threads) do
|
||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||
end
|
||||
if ( not(done) ) then
|
||||
condvar("wait")
|
||||
end
|
||||
end
|
||||
|
||||
if ( results ) then
|
||||
|
||||
Reference in New Issue
Block a user