Skip to content
Commit daf7b53a authored by Sergey Bugaev's avatar Sergey Bugaev Committed by Adhemerval Zanella
Browse files

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: default avatarAdhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: default avatarFlorian Weimer <fweimer@redhat.com>
Signed-off-by: default avatarSergey Bugaev <bugaevc@gmail.com>
parent 21fbc0a1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment