[apparmor] [PATCH] parser: Fix error checking of file opening in features_dir_cb()
Seth Arnold
seth.arnold at canonical.com
Wed Mar 4 02:13:24 UTC 2015
On Tue, Mar 03, 2015 at 08:00:43PM -0600, Tyler Hicks wrote:
> The error path was being taken when openat() return 0 but openat()
> returns -1 on error.
>
> Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
Acked-by: Seth Arnold <seth.arnold at canonical.com>
Thanks
> ---
>
> Another minor bug that I came across while working on the libapparmor API
> changes. Nominated for 2.9 and trunk.
>
> parser/parser_main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/parser/parser_main.c b/parser/parser_main.c
> index 51649ba..1d1cbe6 100644
> --- a/parser/parser_main.c
> +++ b/parser/parser_main.c
> @@ -587,7 +587,9 @@ static int features_dir_cb(DIR *dir, const char *name, struct stat *st,
> if (S_ISREG(st->st_mode)) {
> int len, file;
> int remaining = fst->size - (fst->pos - *fst->buffer);
> - if (!(file = openat(dirfd(dir), name, O_RDONLY))) {
> +
> + file = openat(dirfd(dir), name, O_RDONLY);
> + if (file == -1) {
> PDEBUG("Could not open '%s'", name);
> return -1;
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150303/8f1c6b51/attachment.pgp>
More information about the AppArmor
mailing list