From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7844) id CBDFF3858293; Tue, 9 Aug 2022 09:52:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBDFF3858293 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Noah Goldstein To: glibc-cvs@sourceware.org Subject: [glibc] elf: Replace `strcpy` call with `memcpy` [BZ #29454] X-Act-Checkin: glibc X-Git-Author: Noah Goldstein X-Git-Refname: refs/heads/master X-Git-Oldrev: 8bc3f94a062776abfaf14201fba37bea5328bf92 X-Git-Newrev: 483cfe1a6a33d6335b1901581b41040d2d412511 Message-Id: <20220809095232.CBDFF3858293@sourceware.org> Date: Tue, 9 Aug 2022 09:52:32 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2022 09:52:32 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=483cfe1a6a33d6335b1901581b41040d2d412511 commit 483cfe1a6a33d6335b1901581b41040d2d412511 Author: Noah Goldstein 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); }