this repo has no description
1
fork

Configure Feed

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

Fix proc_pidpath() in vchroot

+42 -1
+18 -1
src/kernel/emulation/linux/misc/proc_info.c
··· 16 16 #include "../simple.h" 17 17 #include "../readline.h" 18 18 #include "../elfcalls_wrapper.h" 19 + #include "../vchroot_expand.h" 19 20 #include <stdbool.h> 20 21 #include <sys/proc.h> 21 22 #include <lkm/api.h> ··· 457 458 static long _proc_pidinfo_pathinfo(int32_t pid, void* buffer, int32_t bufsize) 458 459 { 459 460 char path[64]; 461 + struct vchroot_unexpand_args args; 462 + 460 463 __simple_sprintf(path, "/proc/%d/exe", pid); 464 + 461 465 memset(buffer, 0, bufsize); 462 - return sys_readlink(path, buffer, bufsize); 466 + int rv = sys_readlink(path, buffer, bufsize - 1); 467 + 468 + if (rv < 0) 469 + return rv; 470 + 471 + ((char*)buffer)[rv] = 0; 472 + 473 + strcpy(args.path, buffer); 474 + rv = vchroot_unexpand(&args); 475 + if (rv != 0) 476 + return rv; 477 + 478 + strncpy(buffer, args.path, bufsize); 479 + return strlen(args.path); 463 480 }
+6
src/kernel/emulation/linux/vchroot_expand.h
··· 4 4 5 5 int vchroot_expand(struct vchroot_expand_args* args); 6 6 7 + struct vchroot_unexpand_args 8 + { 9 + char path[4096]; 10 + }; 11 + int vchroot_unexpand(struct vchroot_unexpand_args* args); 12 + 7 13 #endif 8 14
+18
src/kernel/emulation/linux/vchroot_userspace.c
··· 1 1 2 2 #include <lkm/api.h> 3 + #include "vchroot_expand.h" 3 4 #ifdef TEST 4 5 # include <unistd.h> 5 6 # include <sys/stat.h> ··· 457 458 #ifndef TEST 458 459 __simple_printf("fdpath %d -> %s\n", args->fd, args->path); 459 460 #endif 461 + 462 + return 0; 463 + } 464 + 465 + int vchroot_unexpand(struct vchroot_unexpand_args* args) 466 + { 467 + if (memcmp(args->path, prefix_path, prefix_path_len) == 0) 468 + { 469 + int bytes = strlen(args->path + prefix_path_len) + 1; 470 + memmove(args->path, args->path + prefix_path_len, bytes); 471 + } 472 + else 473 + { 474 + int bytes = strlen(args->path) + 1; 475 + memmove(args->path + sizeof(EXIT_PATH) - 1, args->path, bytes); 476 + memcpy(args->path, EXIT_PATH, sizeof(EXIT_PATH) - 1); 477 + } 460 478 461 479 return 0; 462 480 }