mirror of
https://github.com/adulau/aha.git
synced 2024-12-26 18:56:14 +00:00
Avoid maximal recursion error
This commit is contained in:
parent
ddc4d50b77
commit
f8290a30db
1 changed files with 11 additions and 1 deletions
|
@ -119,7 +119,9 @@ class ProcessTrees:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def searchTree(self,pid,ppid):
|
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.foundUser = 0
|
||||||
self.__searchTree(pid,ppid)
|
self.__searchTree(pid,ppid)
|
||||||
#If the process belongs to the system remove it, to free up memory
|
#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(ret,0)
|
||||||
self.assertEqual(len(x.processList.keys()),1)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue