@@ -53,34 +53,43 @@ def calculate(self):
5353 p = obj .Object ("Pointer" , offset = gnotify_addr , vm = self .addr_space )
5454 gnotifications = p .dereference_as (self ._struct_or_class ("OSDictionary" ))
5555
56+ if gnotifications .count > 1024 :
57+ return
58+
5659 ents = obj .Object ('Array' , offset = gnotifications .dictionary ,
5760 vm = self .addr_space ,
5861 targetType = self ._struct_or_class ("dictEntry" ),
5962 count = gnotifications .count )
6063
6164 # walk the current set of notifications
6265 for ent in ents :
63-
6466 if ent == None or not ent .is_valid ():
6567 continue
6668
6769 key = str (ent .key .dereference_as (self ._struct_or_class ("OSString" )))
6870
6971 # get the value
7072 valset = ent .value .dereference_as (self ._struct_or_class ("OSOrderedSet" ))
73+ if valset == None or valset .count > 1024 :
74+ continue
7175
7276 notifiers_ptrs = obj .Object ('Array' , offset = valset .array ,
7377 vm = self .addr_space ,
7478 targetType = 'Pointer' ,
7579 count = valset .count )
76-
80+
81+ if notifiers_ptrs == None :
82+ continue
83+
7784 for ptr in notifiers_ptrs :
7885 notifier = ptr .dereference_as (self ._struct_or_class ("_IOServiceNotifier" ))
7986
8087 if notifier == None :
8188 continue
8289
8390 matches = self .get_matching (notifier )
91+ if matches == []:
92+ continue
8493
8594 # this is the function that handles whatever the notification is for
8695 # this should be only in the kernel or in one of the known IOKit
@@ -98,18 +107,22 @@ def calculate(self):
98107 # returns the list of matching notifiers (serviceMatch) for a notifier as a string
99108 def get_matching (self , notifier ):
100109 matches = []
101-
110+
111+ if notifier .matching .count > 1024 :
112+ return matches
113+
102114 ents = obj .Object ('Array' , offset = notifier .matching .dictionary ,
103115 vm = self .addr_space ,
104116 targetType = self ._struct_or_class ("dictEntry" ),
105117 count = notifier .matching .count )
106118
107119 for ent in ents :
108- if ent == None :
120+ if ent == None or ent . value == None :
109121 continue
110-
122+
111123 match = ent .value .dereference_as (self ._struct_or_class ("OSString" ))
112- matches .append (str (match ))
124+ if len (str (match )) > 0 :
125+ matches .append (str (match ))
113126
114127 return "," .join (matches )
115128
0 commit comments