From: James Carter <jwcart2@gmail.com>
To: Sergei Trofimovich <slyich@gmail.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH] libsemanage: fix src/genhomedircon.c build on `gcc-14` (`-Werror=alloc-size`)
Date: Wed, 6 Dec 2023 15:57:57 -0500 [thread overview]
Message-ID: <CAP+JOzQSEhOqKfa4vSsgYgdkuWPozKtWXdD53cFire8-EtVNhA@mail.gmail.com> (raw)
In-Reply-To: <CAP+JOzRLtgvOjFYveZ6F9_Z8j0Jv4oWh2qM1WCdPnzL6i1hqiw@mail.gmail.com>
On Mon, Dec 4, 2023 at 2:24 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Dec 4, 2023 at 11:17 AM Sergei Trofimovich <slyich@gmail.com> wrote:
> >
> > `gcc-14` added a new `-Walloc-size` warning that makes sure that size of
> > an individual element matches size of a pointed type:
> >
> > https://gcc.gnu.org/PR71219
> >
> > `libsemanage` triggers it on `calloc()` calls where member size is used
> > as `1` (instead of member count):
> >
> > genhomedircon.c: In function 'ignore_setup':
> > genhomedircon.c:152:21:
> > error: allocation of insufficient size '1' for type 'ignoredir_t'
> > {aka 'struct IgnoreDir'} with size '16' [-Werror=alloc-size]
> > 152 | ptr = calloc(sizeof(ignoredir_t),1);
> > | ^
> >
> > Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim
> > ---
> > libsemanage/src/genhomedircon.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
> > index 8f8774d3..66585987 100644
> > --- a/libsemanage/src/genhomedircon.c
> > +++ b/libsemanage/src/genhomedircon.c
> > @@ -149,7 +149,7 @@ static int ignore_setup(char *ignoredirs) {
> >
> > tok = strtok(ignoredirs, ";");
> > while(tok) {
> > - ptr = calloc(sizeof(ignoredir_t),1);
> > + ptr = calloc(1, sizeof(ignoredir_t));
> > if (!ptr)
> > goto err;
> > ptr->dir = strdup(tok);
> > --
> > 2.42.0
> >
> >
prev parent reply other threads:[~2023-12-06 20:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 16:16 [PATCH] libsemanage: fix src/genhomedircon.c build on `gcc-14` (`-Werror=alloc-size`) Sergei Trofimovich
2023-12-04 19:24 ` James Carter
2023-12-06 20:57 ` 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+JOzQSEhOqKfa4vSsgYgdkuWPozKtWXdD53cFire8-EtVNhA@mail.gmail.com \
--to=jwcart2@gmail.com \
--cc=selinux@vger.kernel.org \
--cc=slyich@gmail.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).