All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: Jie Lu <lujie54@huawei.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH 3/3] policycoreutils: fix potential NULL reference in load_checks
Date: Wed, 11 Jan 2023 10:51:36 -0500	[thread overview]
Message-ID: <CAP+JOzQyVh+VdG=HJHrW=9e5_+poJyi4x9Va6Qo3yj-UQV6yyg@mail.gmail.com> (raw)
In-Reply-To: <CAP+JOzSEFRrejgab331mG8dFgv2YwR=WYjC7Qv42XMkoOnDw9g@mail.gmail.com>

On Fri, Dec 16, 2022 at 11:07 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Dec 5, 2022 at 7:13 AM Jie Lu <lujie54@huawei.com> wrote:
> >
> > In load_checks(), add return check for malloc() to avoid NULL reference.
> >
> > Signed-off-by: Jie Lu <lujie54@huawei.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>

This patch, but not the other two, has been merged.
Thanks,
Jim

>
> > ---
> >  policycoreutils/sestatus/sestatus.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/policycoreutils/sestatus/sestatus.c b/policycoreutils/sestatus/sestatus.c
> > index 7dcc9944..6c95828e 100644
> > --- a/policycoreutils/sestatus/sestatus.c
> > +++ b/policycoreutils/sestatus/sestatus.c
> > @@ -140,6 +140,8 @@ static void load_checks(char *pc[], int *npc, char *fc[], int *nfc)
> >                                         pc[*npc] =
> >                                             (char *)malloc((buf_len) *
> >                                                            sizeof(char));
> > +                                       if (!pc[*npc])
> > +                                               break;
> >                                         memcpy(pc[*npc], bufp, buf_len);
> >                                         (*npc)++;
> >                                         bufp = NULL;
> > @@ -150,6 +152,8 @@ static void load_checks(char *pc[], int *npc, char *fc[], int *nfc)
> >                                         fc[*nfc] =
> >                                             (char *)malloc((buf_len) *
> >                                                            sizeof(char));
> > +                                       if (!fc[*nfc])
> > +                                               break;
> >                                         memcpy(fc[*nfc], bufp, buf_len);
> >                                         (*nfc)++;
> >                                         bufp = NULL;
> > --
> > 2.27.0
> >

  reply	other threads:[~2023-01-11 15:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05  9:36 [PATCH 1/3] libselinux: fix potential NULL reference and memory leak in audit2why Jie Lu
2022-12-05  9:36 ` [PATCH 2/3] libsepol: fix potential memory leak in common_copy_callback Jie Lu
2022-12-16 16:06   ` James Carter
2022-12-05  9:36 ` [PATCH 3/3] policycoreutils: fix potential NULL reference in load_checks Jie Lu
2022-12-16 16:07   ` James Carter
2023-01-11 15:51     ` James Carter [this message]
2022-12-16 16:03 ` [PATCH 1/3] libselinux: fix potential NULL reference and memory leak in audit2why James Carter

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+JOzQyVh+VdG=HJHrW=9e5_+poJyi4x9Va6Qo3yj-UQV6yyg@mail.gmail.com' \
    --to=jwcart2@gmail.com \
    --cc=lujie54@huawei.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.