this repo has no description
1
fork

Configure Feed

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

mldr: Unexpand vchroot path for interpreters

+26
+26
src/startup/mldr/mldr.c
··· 76 76 #endif 77 77 static void setup_stack32(const char* filepath, struct load_results* lr); 78 78 79 + // this is called when argv[0] specifies an interpreter and we need to "unexpand" it (i.e. convert it from a Linux path to a vchrooted path) 80 + static void vchroot_unexpand_interpreter(struct load_results* lr); 81 + 79 82 // UUID of the main executable 80 83 uint8_t exe_uuid[16]; 81 84 ··· 163 166 mldr_load_results.argv[i] = mldr_load_results.argv[i + 1]; 164 167 } 165 168 mldr_load_results.argv[mldr_load_results.argc] = NULL; 169 + 170 + if (p == NULL) { 171 + vchroot_unexpand_interpreter(&mldr_load_results); 172 + } 166 173 167 174 if (mldr_load_results._32on64) 168 175 setup_stack32(filename, &mldr_load_results); ··· 547 554 # error Unsupported platform! 548 555 #endif 549 556 }; 557 + 558 + static void vchroot_unexpand_interpreter(struct load_results* lr) { 559 + static char unexpanded[4096]; 560 + size_t length; 561 + 562 + if (lr->root_path) { 563 + length = strlen(lr->argv[0]); 564 + 565 + if (strncmp(lr->argv[0], lr->root_path, lr->root_path_length) == 0) { 566 + memmove(unexpanded, lr->argv[0] + lr->root_path_length, length - lr->root_path_length + 1); 567 + } else { 568 + // FIXME: potential buffer overflow 569 + memmove(unexpanded + sizeof(SYSTEM_ROOT) - 1, lr->argv[0], length + 1); 570 + memcpy(unexpanded, SYSTEM_ROOT, sizeof(SYSTEM_ROOT) - 1); 571 + } 572 + 573 + lr->argv[0] = unexpanded; 574 + } 575 + };