From: Noah Goldstein <goldstein.w.n@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
"Carlos O'Donell" <carlos@systemhalted.org>
Subject: Re: [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454]
Date: Wed, 10 Aug 2022 11:29:49 +0800 [thread overview]
Message-ID: <CAFUsyf+-C3F6LS9Ui4kDajC227MFGQMK0iLgX7w8XW7yo=SgXA@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOoBW4x==YSLeonNQLczAO8XLeXf4BEk_gAuz6TCD3+oRw@mail.gmail.com>
On Mon, Aug 8, 2022 at 10:24 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, Aug 7, 2022 at 8:26 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > GCC normally does this optimization for us in
> > strlen_pass::handle_builtin_strcpy but only for optimized
> > build. To avoid needing to include strcpy.S in the rtld build to
> > support the debug build, just do the optimization by hand.
> > ---
> > elf/dl-cache.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/elf/dl-cache.c b/elf/dl-cache.c
> > index 8bbf110d02..b97c17b3a9 100644
> > --- a/elf/dl-cache.c
> > +++ b/elf/dl-cache.c
> > @@ -509,8 +509,9 @@ _dl_load_cache_lookup (const char *name)
> > we are accessing. Therefore we must make the copy of the
> > mapping data without using malloc. */
> > char *temp;
> > - temp = alloca (strlen (best) + 1);
> > - strcpy (temp, best);
> > + size_t best_len = strlen (best) + 1;
> > + temp = alloca (best_len);
> > + memcpy (temp, best, best_len);
> > return __strdup (temp);
> > }
> >
> > --
> > 2.34.1
> >
>
> LGTM.
>
> Thanks.
>
> --
> H.J.
Any objections to backporting this to 2.36?
next prev parent reply other threads:[~2022-08-10 3:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 3:26 [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S Noah Goldstein
2022-08-08 3:26 ` [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] Noah Goldstein
2022-08-08 10:19 ` Yann Droneaud
2022-08-08 14:23 ` H.J. Lu
2022-08-10 3:29 ` Noah Goldstein [this message]
2022-08-08 14:21 ` [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S H.J. Lu
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='CAFUsyf+-C3F6LS9Ui4kDajC227MFGQMK0iLgX7w8XW7yo=SgXA@mail.gmail.com' \
--to=goldstein.w.n@gmail.com \
--cc=carlos@systemhalted.org \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.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).