Skip to content

Commit

Permalink
xzre: add opt-in environment variable to run the shared entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Apr 15, 2024
1 parent 35155d9 commit 9a1947a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions xzre.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,20 @@ void xzre_backdoor_setup(){

static inline __attribute__((always_inline))
void main_shared(){
char *trigger = getenv("XZRE_MAIN");
if(!trigger || strcmp(trigger, "1")){
return;
}
unsetenv("XZRE_MAIN");

// prevent fork bomb in system command
unsetenv("LD_PRELOAD");
xzre_secret_data_bypass();

void *elf_addr = get_main_elf();
if(!elf_addr){
puts("Failed to get main elf");
exit(1);
return;
}

elf_handles_t handles = {0};
Expand All @@ -244,8 +250,7 @@ void main_shared(){
item->func_end ? PTRDIFF(item->func_end, elf_addr) : 0,
item->xref ? PTRDIFF(item->xref, elf_addr) : 0);
}

xzre_backdoor_setup();
//xzre_backdoor_setup();
puts("main_shared(): OK");
}

Expand Down

0 comments on commit 9a1947a

Please sign in to comment.