[apparmor] [patch] fix crash in aa.py / check_for_LD_XXX()

Kshitij Gupta kgupta8592 at gmail.com
Sun Aug 17 16:11:50 UTC 2014


Hello,

On Sun, Aug 17, 2014 at 9:26 PM, Christian Boltz <apparmor at cboltz.de> wrote:
> Hello,
>
> this patch fixes the crash in aa.py / check_for_LD_XXX() I reported last
> night:
>
>   File "/home/cb/apparmor/HEAD-CLEAN/utils/apparmor/aa.py", line 126, in check_for_LD_XXX
>     for line in f_in:
> [...]
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xf8 in position 40: ordinal not in range(128)
>
>
> While on it, I also replaced usage of the "found" variable by "return"
> statements, which should bring a small performance improvement - if we
> have a match, it's superfluous to continue searching.
>
> The patch also adds me to the copyright header ;-)
>
>
> === modified file 'utils/apparmor/aa.py'
> --- utils/apparmor/aa.py        2014-07-22 10:56:37 +0000
> +++ utils/apparmor/aa.py        2014-08-17 15:48:37 +0000
> @@ -1,5 +1,6 @@
>  # ----------------------------------------------------------------------
>  #    Copyright (C) 2013 Kshitij Gupta <kgupta8592 at gmail.com>
> +#    Copyright (C) 2014 Christian Boltz <apparmor at cboltz.de>
>  #
>  #    This program is free software; you can redistribute it and/or
>  #    modify it under the terms of version 2 of the GNU General Public
> @@ -115,18 +116,17 @@
>  def check_for_LD_XXX(file):
>      """Returns True if specified program contains references to LD_PRELOAD or
>      LD_LIBRARY_PATH to give the Px/Ux code better suggestions"""
> -    found = False
>      if not os.path.isfile(file):
>          return False
>      size = os.stat(file).st_size
>      # Limit to checking files under 100k for the sake of speed
>      if size > 100000:
>          return False
> -    with open_file_read(file, encoding='ascii') as f_in:
> +    with open(file, 'rb') as f_in:
>          for line in f_in:
> -            if 'LD_PRELOAD' in line or 'LD_LIBRARY_PATH' in line:
> -                found = True
> -    return found
> +            if b'LD_PRELOAD' in line or b'LD_LIBRARY_PATH' in line:
> +                return True
> +    return False
>
>  def fatal_error(message):
>      # Get the traceback to the message
>
>
>

Thanks for the patch. :-)

Acked-by: Kshitij Gupta <kgupta8592 at gmail.com>.

Regards,

Kshitij Gupta

> Regards,
>
> Christian Boltz
> --
>> You cannot mix selections and patterns in a product - and we
>> will remove all selection support now.
> AAARRRRRRGGGGGG. Needing to re-write makeSUSEdvd again. ;-)
> It looks like you do all this on purpose, just to anoy me. :-D
> [> Andreas Jaeger and houghi in opensuse]
>
>
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor



More information about the AppArmor mailing list