diff --git a/lib/msf/core/task_manager.rb b/lib/msf/core/task_manager.rb index 0c3acca3f3..0abfe13fff 100644 --- a/lib/msf/core/task_manager.rb +++ b/lib/msf/core/task_manager.rb @@ -16,7 +16,6 @@ class TaskManager attr_accessor :proc attr_accessor :source attr_accessor :exception - attr_accessor :retval # # Create a new task @@ -41,7 +40,7 @@ class TaskManager # Run the associated proc # def run(*args) - self.retval = self.proc.call(*args) if self.proc + self.proc.call(*args) if self.proc end end @@ -158,6 +157,8 @@ class TaskManager else task.run(self, task) end + rescue ::ThreadError + # Ignore these (caused by a return inside of the proc) rescue ::Exception => e if(e.class == ::Timeout::Error) diff --git a/test/tests/04_task_manager_test.rb b/test/tests/04_task_manager_test.rb index 6e9c1d9394..3a98636d62 100644 --- a/test/tests/04_task_manager_test.rb +++ b/test/tests/04_task_manager_test.rb @@ -86,5 +86,17 @@ describe Msf::TaskManager do t.status.should == :dropped t.exception.class.should == ::NoMethodError end + + it "should handle a bad proc return" do + tm = Msf::TaskManager.new($msf) + t = Msf::TaskManager::Task.new(Proc.new { return 12345 }) + + tm.start + tm.queue_task(t) + sleep(0.5) + + t.status.should == :done + t.exception.should == nil + end end