Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: crash in
postject_find_resource()
on Linux (#77)
* fix: crash in `postject_find_resource()` on Linux The program headers base address values returned by `getauxval(AT_PHDR)` and `dl_iterate_phdr()` are identical only on `g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0`. However, the values are totally different on `clang version 10.0.0-4ubuntu1` and `g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-16)`. Since the `dl_iterate_phdr()` approach seems to work for all the 3 compilers, I think we should proceed with that. Fixes: #70 Refs: #76 Signed-off-by: Darshan Sen <[email protected]> * chore: remove unnecessary if block Signed-off-by: Darshan Sen <[email protected]> * fix: only iterate the main executable program headers The resource gets injected in the main executable, so there is no need to iterate the other shared libraries that are loaded by the program. This also resolves a security concern. Refs: #77 (review) Signed-off-by: Darshan Sen <[email protected]> * chore: shorten change Signed-off-by: Darshan Sen <[email protected]> * test: add comment about _GNU_SOURCE Signed-off-by: Darshan Sen <[email protected]> --------- Signed-off-by: Darshan Sen <[email protected]>
- Loading branch information