about summary refs log tree commit diff
path: root/elf/global.c
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-06-17 19:40:25 +0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-06-26 10:04:31 -0300
commitdaf7b53a3c93e99ce66837e908984148fb9f11ee (patch)
treeebeaffc635c3e463725fcdc213d8a3f9670305a7 /elf/global.c
parent21fbc0a19366f89638a30eef2b53c6d4baafdb88 (diff)
downloadglibc-daf7b53a3c93e99ce66837e908984148fb9f11ee.tar.gz
glibc-daf7b53a3c93e99ce66837e908984148fb9f11ee.tar.xz
glibc-daf7b53a3c93e99ce66837e908984148fb9f11ee.zip
elf: Port ldconfig away from stack-allocated paths
ldconfig was allocating PATH_MAX bytes on the stack for the library file
name. The issues with PATH_MAX usage are well documented [0][1]; even if
a program does not rely on paths being limited to PATH_MAX bytes,
allocating 4096 bytes on the stack for paths that are typically rather
short (strlen ("/lib64/libc.so.6") is 16) is wasteful and dangerous.

[0]: https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
[1]: https://eklitzke.org/path-max-is-tricky

Instead, make use of asprintf to dynamically allocate memory of just the
right size on the heap.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Diffstat (limited to 'elf/global.c')
0 files changed, 0 insertions, 0 deletions