mirror of
https://github.com/rofl0r/proxychains-ng
synced 2025-01-09 14:52:52 +08:00
Make sure preload library path is absolute. This fixes issues where a chdir is followed by a process fork, which can cause the library to not be found.
This commit is contained in:
parent
ce4c71078e
commit
369f92670c
12
src/main.c
12
src/main.c
@ -131,6 +131,14 @@ int main(int argc, char *argv[]) {
|
|||||||
if(!quiet)
|
if(!quiet)
|
||||||
fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
|
fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
|
||||||
|
|
||||||
|
snprintf(path=pbuf, sizeof(pbuf), "%s/%s", prefix, dll_name);
|
||||||
|
if (path[0] != '/'){
|
||||||
|
path = realpath(path, NULL);
|
||||||
|
snprintf(pbuf, sizeof(pbuf), "%s", path);
|
||||||
|
free(path);
|
||||||
|
path = pbuf;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef IS_MAC
|
#ifdef IS_MAC
|
||||||
putenv("DYLD_FORCE_FLAT_NAMESPACE=1");
|
putenv("DYLD_FORCE_FLAT_NAMESPACE=1");
|
||||||
#define LD_PRELOAD_ENV "DYLD_INSERT_LIBRARIES"
|
#define LD_PRELOAD_ENV "DYLD_INSERT_LIBRARIES"
|
||||||
@ -143,8 +151,8 @@ int main(int argc, char *argv[]) {
|
|||||||
#define LD_PRELOAD_SEP " "
|
#define LD_PRELOAD_SEP " "
|
||||||
#endif
|
#endif
|
||||||
char *old_val = getenv(LD_PRELOAD_ENV);
|
char *old_val = getenv(LD_PRELOAD_ENV);
|
||||||
snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s/%s%s%s",
|
snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s%s%s",
|
||||||
prefix, dll_name,
|
path,
|
||||||
/* append previous LD_PRELOAD content, if existent */
|
/* append previous LD_PRELOAD content, if existent */
|
||||||
old_val ? LD_PRELOAD_SEP : "",
|
old_val ? LD_PRELOAD_SEP : "",
|
||||||
old_val ? old_val : "");
|
old_val ? old_val : "");
|
||||||
|
Loading…
Reference in New Issue
Block a user