[apparmor] [PATCH 1/2] utils: Fix infinite loop when converting an unrecognized mode string
Tyler Hicks
tyhicks at canonical.com
Wed Apr 23 18:01:05 UTC 2014
Bug: https://bugs.launchpad.net/bugs/1307665
When str_to_mode() was given a string containing unknown mode
characters, it entered an infinite loop. The case of the MODE_MAP_RE
regex string not matching the mode string was being ignored.
This patch makes it so that the loop breaks when MODE_MAP_RE no longer
matches the mode string. This occurs when all of the valid mode
characters have been processed and only invalid mode characters remain.
Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
---
utils/apparmor/aamode.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/utils/apparmor/aamode.py b/utils/apparmor/aamode.py
index a761747..a9fd307 100644
--- a/utils/apparmor/aamode.py
+++ b/utils/apparmor/aamode.py
@@ -91,8 +91,9 @@ def sub_str_to_mode(string):
return mode
while string:
tmp = MODE_MAP_RE.search(string)
- if tmp:
- tmp = tmp.groups()[0]
+ if not tmp:
+ break
+ tmp = tmp.groups()[0]
string = MODE_MAP_RE.sub('', string, 1)
if tmp and MODE_HASH.get(tmp, False):
mode |= MODE_HASH[tmp]
--
1.9.1
More information about the AppArmor
mailing list