1
0
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:
patrik
2012-08-29 05:37:56 +00:00
parent c71478d91f
commit 448bb5a71b
22 changed files with 72 additions and 26 deletions

View File

@@ -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

View File

@@ -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 = {}

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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 = {}

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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