2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

Merge Detect endless #include loop when parsing profiles

If an include file includes itsself (for example if local/foo has '#include <local/foo>'), print a warning instead of calling load_include() again and again.

This fixes a crash when hitting such a case: RecursionError: maximum recursion depth exceeded while calling a Python object

Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1184779 for the tools. The parser will also need a fix.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/742
Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2021-04-21 20:06:49 +00:00
commit 8aa15c7fbe

View File

@ -1855,7 +1855,11 @@ def parse_profile_data(data, file, do_include, in_preamble):
if rule_name == 'inc_ie':
for incname in rule_obj.get_full_paths(profile_dir):
load_include(incname, in_preamble)
if incname == file:
# warn about endless loop, and don't call load_include() (again) for this file
aaui.UI_Important(_('WARNING: endless loop detected: file %s includes itsself' % incname))
else:
load_include(incname, in_preamble)
elif RE_PROFILE_START.search(line): # Starting line of a profile
# in_contained_hat is needed to know if we are already in a profile or not. (Simply checking if we are in a hat doesn't work,