From: James Carter <jwcart2@gmail.com>
To: Jordan Williams <jordan@jwillikers.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH] libselinux/src/Makefile: fix reallocarray strlcpy detection
Date: Wed, 13 Mar 2024 18:52:09 -0400 [thread overview]
Message-ID: <CAP+JOzQ1iE7QZZAKoLy-BN9n=Hm-MfejdxtKzu1O+EtgH-mU8A@mail.gmail.com> (raw)
In-Reply-To: <d5120a64-04f3-444d-aaf8-3cfc6c1d9953@jwillikers.com>
On Fri, Mar 1, 2024 at 12:03 PM Jordan Williams <jordan@jwillikers.com> wrote:
>
> Pass CFLAGS and LDFLAGS when checking for realocarray and strlcpy.
> This brings things inline with the fixes for libsepol/src/Makefile.
> This better supports cross-compiling scenarios.
> There, flags like -sysroot need to included when running these checks.
>
> Signed-off-by: Jordan Williams <jordan@jwillikers.com>
>
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index d3b981fc..3a9b5300 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -104,13 +104,13 @@ override CFLAGS += -I../include -D_GNU_SOURCE
> $(DISABLE_FLAGS) $(PCRE_CFLAGS)
>
> # check for strlcpy(3) availability
> H := \#
> -ifeq (yes,$(shell printf '${H}include <string.h>\nint
> main(void){char*d,*s;strlcpy(d, s, 0);return 0;}' | $(CC) -x c -o
> /dev/null - >/dev/null 2>&1 && echo yes))
> +ifeq (yes,$(shell printf '${H}include <string.h>\nint
> main(void){char*d,*s;strlcpy(d, s, 0);return 0;}' | $(CC) $(CFLAGS)
> $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
> override CFLAGS += -DHAVE_STRLCPY
> endif
>
> # check for reallocarray(3) availability
> H := \#
> -ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
> main(void){reallocarray(NULL, 0, 0);return 0;}' | $(CC) -x c -o
> /dev/null - >/dev/null 2>&1 && echo yes))
> +ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
> main(void){reallocarray(NULL, 0, 0);return 0;}' | $(CC) $(CFLAGS)
> $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
> override CFLAGS += -DHAVE_REALLOCARRAY
> endif
>
The default CFLAGS causes the compilation to fail even if strlcpy() or
reallocarray() exist.
See if the patch I sent to the list works for you.
Thanks,
Jim
> --
> 2.44.0
>
>
prev parent reply other threads:[~2024-03-13 22:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 16:32 [PATCH] libselinux/src/Makefile: fix reallocarray strlcpy detection Jordan Williams
2024-03-13 22:52 ` 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+JOzQ1iE7QZZAKoLy-BN9n=Hm-MfejdxtKzu1O+EtgH-mU8A@mail.gmail.com' \
--to=jwcart2@gmail.com \
--cc=jordan@jwillikers.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).