this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix a crash in libelfloader, update submodules

+7 -9
+7 -9
src/libelfloader/loader.c
··· 55 55 #define ELF_PAGEOFFSET(_v) ((_v) & (ELF_MIN_ALIGN-1)) 56 56 #define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1)) 57 57 58 - extern char** environ; 59 - 60 58 struct loader_context 61 59 { 62 60 uintptr_t interp_entry; ··· 67 65 uintptr_t interp_base; 68 66 }; 69 67 70 - static void run(const char* path); 68 + static void run(const char* path, const char** envp); 71 69 static void load(const char* path, struct loader_context* lc, bool isInterp); 72 70 static void loader_return(void); 73 71 static const char SYSTEM_ROOT[] = "/Volumes/SystemRoot"; ··· 77 75 78 76 #ifndef TEST 79 77 __attribute__((constructor)) 80 - static void runDummy(void) 78 + static void runDummy(int argc, const char** argv, const char** envp) 81 79 { 82 80 _elfcalls = (struct elf_calls*) malloc(sizeof(struct elf_calls)); 83 - run(DUMMY_PATH); 81 + run(DUMMY_PATH, envp); 84 82 } 85 83 #endif 86 84 87 - void run(const char* path) 85 + void run(const char* path, const char** envp) 88 86 { 89 87 struct loader_context lc; 90 88 unsigned long *stack, *stackmem; ··· 111 109 ptrcount += 4; // argv 112 110 113 111 // environ 114 - for (int i = 0; environ[i] != NULL; i++) 112 + for (int i = 0; envp[i] != NULL; i++) 115 113 ptrcount++; 116 114 ptrcount++; 117 115 ··· 132 130 stack[pos++] = 0; 133 131 134 132 135 - for (int i = 0; environ[i] != NULL; i++) 136 - stack[pos++] = (unsigned long) environ[i]; 133 + for (int i = 0; envp[i] != NULL; i++) 134 + stack[pos++] = (unsigned long) envp[i]; 137 135 138 136 #ifdef __linux__ // For testing 139 137 getrandom(entropy, sizeof(entropy), 0);