Skip to content
This repository was archived by the owner on Feb 16, 2025. It is now read-only.

Commit efc368c

Browse files
author
Markus Raab
committed
getenv: handle double-wrapping situation
1 parent 26b2e6a commit efc368c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libgetenv/src/getenv.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ extern "C" int __libc_start_main(int *(main) (int, char * *, char * *), int argc
404404
{
405405
elektraLockMutex(); // lock for dlsym
406406
LOG << "wrapping main" << endl;
407+
if (start.d)
408+
{ // double wrapping situation, do not reopen, just forward to next __libc_start_main
409+
start.d = dlsym(RTLD_NEXT, "__libc_start_main");
410+
int ret = (*start.f)(main, argc, argv, init, fini, rtld_fini, stack_end);
411+
elektraUnlockMutex();
412+
return ret;
413+
}
414+
407415
start.d = dlsym(RTLD_NEXT, "__libc_start_main");
408416
sym.d = dlsym(RTLD_NEXT, "getenv");
409417
ssym.d = dlsym(RTLD_NEXT, "secure_getenv");

0 commit comments

Comments
 (0)