SELinux Archive mirror
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: luhuaxin1@huawei.com
Cc: selinux@vger.kernel.org, fangxiuning@huawei.com,
	zhujianwei7@huawei.com, shenyining@huawei.com
Subject: Re: [PATCH v1] libsepol: add check for category value before printing
Date: Tue, 14 Nov 2023 15:39:28 -0500	[thread overview]
Message-ID: <CAP+JOzRTW1mJH2VT143OOYCaM7xbNytPukXMoY3gfwCJX1FGhg@mail.gmail.com> (raw)
In-Reply-To: <20231113232750.48706-1-luhuaxin1@huawei.com>

On Mon, Nov 13, 2023 at 8:59 PM <luhuaxin1@huawei.com> wrote:
>
> From: Huaxin Lu <luhuaxin1@huawei.com>
>
> In mls_semantic_level_expand(), there is a explicitly determine
> whether category is 0, which may cause an potential integer
> overflow in error branch.
>
> Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
> ---
>  libsepol/src/expand.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
> index ee5f9185..9ed22bfd 100644
> --- a/libsepol/src/expand.c
> +++ b/libsepol/src/expand.c
> @@ -945,8 +945,8 @@ int mls_semantic_level_expand(mls_semantic_level_t * sl, mls_level_t * l,
>         for (cat = sl->cat; cat; cat = cat->next) {
>                 if (!cat->low || cat->low > cat->high) {
>                         ERR(h, "Category range is not valid %s.%s",
> -                           p->p_cat_val_to_name[cat->low - 1],
> -                           p->p_cat_val_to_name[cat->high - 1]);
> +                           cat->low > 0 ? p->p_cat_val_to_name[cat->low - 1] : "n/a",
> +                           cat->high > 0 ? p->p_cat_val_to_name[cat->high - 1] : "n/a");

I would prefer "Invalid", "Bad Category", "NULL", or something along
those lines instead of "n/a".
Thanks,
Jim


>                         return -1;
>                 }
>                 for (i = cat->low - 1; i < cat->high; i++) {
> --
> 2.33.0
>

      reply	other threads:[~2023-11-14 20:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 23:27 [PATCH v1] libsepol: add check for category value before printing luhuaxin1
2023-11-14 20:39 ` James Carter [this message]

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=CAP+JOzRTW1mJH2VT143OOYCaM7xbNytPukXMoY3gfwCJX1FGhg@mail.gmail.com \
    --to=jwcart2@gmail.com \
    --cc=fangxiuning@huawei.com \
    --cc=luhuaxin1@huawei.com \
    --cc=selinux@vger.kernel.org \
    --cc=shenyining@huawei.com \
    --cc=zhujianwei7@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).