aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2022-08-08 11:26:22 +0800
committerNoah Goldstein <goldstein.w.n@gmail.com>2022-08-09 17:00:03 +0800
commit483cfe1a6a33d6335b1901581b41040d2d412511 (patch)
tree09d8edb50a9a14e45263b7d9eda26fefdd4a6eb6 /elf
parent8bc3f94a062776abfaf14201fba37bea5328bf92 (diff)
downloadglibc-483cfe1a6a33d6335b1901581b41040d2d412511.zip
glibc-483cfe1a6a33d6335b1901581b41040d2d412511.tar.gz
glibc-483cfe1a6a33d6335b1901581b41040d2d412511.tar.bz2
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.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-cache.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/elf/dl-cache.c b/elf/dl-cache.c
index 8bbf110..b97c17b 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);
}