[apparmor] [PATCH 1/2] utils: Fix infinite loop when converting an unrecognized mode string

Christian Boltz apparmor at cboltz.de
Wed Apr 23 20:13:22 UTC 2014


Hello,

Am Mittwoch, 23. April 2014 schrieb Tyler Hicks:
> 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]

Acked-by: Christian Boltz <apparmor at cboltz.de>


Regards,

Christian Boltz
-- 
I guess that mkinitrd has become an official victim of our
attempts to move from into the /usr space. 
[Raymond Wooninck in https://bugzilla.novell.com/787085#c10]




More information about the AppArmor mailing list