All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ondrej Mosnacek <omosnace@redhat.com>
To: Richard Filo <rfilo@redhat.com>
Cc: SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH v2] libselinux: Add missing errno setup
Date: Mon, 4 May 2020 11:01:45 +0200	[thread overview]
Message-ID: <CAFqZXNs88P_VeYgO=9nOX1Z2vpPUVgHxTTqyk6Rj-peqhyN-bA@mail.gmail.com> (raw)
In-Reply-To: <20200504084507.92526-1-rfilo@redhat.com>

On Mon, May 4, 2020 at 10:45 AM Richard Filo <rfilo@redhat.com> wrote:
> Errno is not set to ENOENT when lookup_all() doesn't find any match.
>
> fixes: https://src.fedoraproject.org/tests/selinux/issue/51
>
> Signed-off-by: Richard Filo <rfilo@redhat.com>
> ---
>  libselinux/src/label_file.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
> index 300625c2..113bb9b7 100644
> --- a/libselinux/src/label_file.c
> +++ b/libselinux/src/label_file.c
> @@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec,
>                         goto finish;
>                 }
>         }
> +       if (result && !result[0])
> +               errno = ENOENT;

Sorry for not spotting this earlier, but there is no need to check if
result != NULL, because it will always be non-NULL at this point. So
you should only do the second part of the check (!result[0]). The
check under the "finish" label needs to check both, because you can
get there also via the allocation-failed path, where "result" would be
NULL.

>
>  finish:
>         free(clean_key);
> --
> 2.25.2
>

-- 
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.


  reply	other threads:[~2020-05-04  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 14:16 [PATCH] libselinux: Add missing errno setup Richard Filo
2020-04-06 16:55 ` Ondrej Mosnacek
2020-05-04  8:45   ` [PATCH v2] " Richard Filo
2020-05-04  9:01     ` Ondrej Mosnacek [this message]
2020-05-04 10:38       ` [PATCH v3] " Richard Filo
2020-05-04 11:08         ` Ondrej Mosnacek
2020-05-06 14:10           ` Petr Lautrbach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFqZXNs88P_VeYgO=9nOX1Z2vpPUVgHxTTqyk6Rj-peqhyN-bA@mail.gmail.com' \
    --to=omosnace@redhat.com \
    --cc=rfilo@redhat.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.