From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7844) id 124E63858C74; Thu, 11 Aug 2022 15:32:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 124E63858C74 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/release/2.36/master] elf: Replace `strcpy` call with `memcpy` [BZ #29454] X-Act-Checkin: glibc X-Git-Author: Noah Goldstein X-Git-Refname: refs/heads/release/2.36/master X-Git-Oldrev: ac47d8f6cf9744139adb12f540fb9cc610cac579 X-Git-Newrev: 302bc33bc53c787da6e74162a7092e9c0fb964a8 Message-Id: <20220811153231.124E63858C74@sourceware.org> Date: Thu, 11 Aug 2022 15:32:31 +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: Thu, 11 Aug 2022 15:32:31 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=302bc33bc53c787da6e74162a7092e9c0fb964a8 commit 302bc33bc53c787da6e74162a7092e9c0fb964a8 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. (cherry picked from commit 483cfe1a6a33d6335b1901581b41040d2d412511) 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); }