public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Noah Goldstein <nwg@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] elf: Replace `strcpy` call with `memcpy` [BZ #29454] Date: Tue, 9 Aug 2022 09:52:32 +0000 (GMT) [thread overview] Message-ID: <20220809095232.CBDFF3858293@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=483cfe1a6a33d6335b1901581b41040d2d412511 commit 483cfe1a6a33d6335b1901581b41040d2d412511 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Mon Aug 8 11:26:22 2022 +0800 elf: Replace `strcpy` call with `memcpy` [BZ #29454] 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. Diff: --- 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); }
reply other threads:[~2022-08-09 9:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220809095232.CBDFF3858293@sourceware.org \ --to=nwg@sourceware.org \ --cc=glibc-cvs@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: linkBe 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).