From: James Carter <jwcart2@gmail.com>
To: "Christian Göttsche" <cgzones@googlemail.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH 1/5] semodule_link: avoid NULL dereference on OOM
Date: Thu, 16 Nov 2023 09:56:45 -0500 [thread overview]
Message-ID: <CAP+JOzSZXP-4HbwSe=k9ixnVk0f1JV6dob-AWtcpaeGNFUKX_A@mail.gmail.com> (raw)
In-Reply-To: <CAP+JOzRd6GbNJXykF-0jCscXyvxntBvZpF-sE1wiKwSt3paZRw@mail.gmail.com>
On Mon, Nov 13, 2023 at 4:43 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Thu, Nov 9, 2023 at 8:53 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > In case the initial calloc(3) call fails the variable mods is still NULL
> > while its size hint num_mods is set.
> >
> > Reported by Clang Analyzer:
> >
> > semodule_link.c:182:29: warning: Array access (from variable 'mods') results in a null pointer dereference [core.NullDereference]
> > 182 | sepol_module_package_free(mods[i]);
> > | ^~~~~~~
> >
> > Fixes: 63e798a2034a ("semodule_link: update")
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> For these five patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>
These five patches have been merged.
Thanks,
Jim
> > ---
> > semodule-utils/semodule_link/semodule_link.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/semodule-utils/semodule_link/semodule_link.c b/semodule-utils/semodule_link/semodule_link.c
> > index 0f157bd9..58fca34d 100644
> > --- a/semodule-utils/semodule_link/semodule_link.c
> > +++ b/semodule-utils/semodule_link/semodule_link.c
> > @@ -178,9 +178,11 @@ failure:
> > ret = EXIT_FAILURE;
> >
> > cleanup:
> > - for (i = 0; i < num_mods; i++)
> > - sepol_module_package_free(mods[i]);
> > - free(mods);
> > + if (mods) {
> > + for (i = 0; i < num_mods; i++)
> > + sepol_module_package_free(mods[i]);
> > + free(mods);
> > + }
> > sepol_module_package_free(base);
> >
> > return ret;
> > --
> > 2.42.0
> >
prev parent reply other threads:[~2023-11-16 14:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 13:53 [PATCH 1/5] semodule_link: avoid NULL dereference on OOM Christian Göttsche
2023-11-09 13:53 ` [PATCH 2/5] libsepol: set number of target names Christian Göttsche
2023-11-09 13:53 ` [PATCH 3/5] libselinux: fix memory leak in customizable_init() Christian Göttsche
2023-11-09 13:53 ` [PATCH 4/5] libsepol: avoid leak in OOM branch Christian Göttsche
2023-11-09 13:53 ` [PATCH 5/5] libsepol: avoid memory corruption on realloc failure Christian Göttsche
2023-11-13 21:43 ` [PATCH 1/5] semodule_link: avoid NULL dereference on OOM James Carter
2023-11-16 14:56 ` 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+JOzSZXP-4HbwSe=k9ixnVk0f1JV6dob-AWtcpaeGNFUKX_A@mail.gmail.com' \
--to=jwcart2@gmail.com \
--cc=cgzones@googlemail.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 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).