From f8290a30db84ea541e0cf55ff365a3b2fc370c65 Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Mon, 18 Jan 2010 09:39:24 +0100 Subject: [PATCH] Avoid maximal recursion error --- aha/ahalib.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/aha/ahalib.py b/aha/ahalib.py index 0228a4b215a..c7c766632be 100644 --- a/aha/ahalib.py +++ b/aha/ahalib.py @@ -119,7 +119,9 @@ class ProcessTrees: pass def searchTree(self,pid,ppid): - #Make sure that pid is different from ppid -> to avoid recursion error + if pid == ppid: + # Avoid recursion error + return 0 self.foundUser = 0 self.__searchTree(pid,ppid) #If the process belongs to the system remove it, to free up memory @@ -190,6 +192,14 @@ class TestProcessTree(unittest.TestCase): self.assertEqual(ret,0) self.assertEqual(len(x.processList.keys()),1) + def testRecurionErrorBreak(self): + #FIXME can an attacker create a process having its own parent? + x = ProcessTrees() + x.addUser(123) + x.searchTree(123,222) + ret = x.searchTree(222,222) + self.assertEqual(ret,0) + if __name__ == '__main__': unittest.main()