From dd6f7858fa90858e4b733cca6dff41d537778706 Mon Sep 17 00:00:00 2001 From: "Lucas C. Villa Real" Date: Wed, 16 Aug 2017 11:11:20 -0300 Subject: [PATCH] Assertions + fixes to arguments passed to posix_spawn/spawnp. --- src/lib/RunnerRedirect.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/RunnerRedirect.c b/src/lib/RunnerRedirect.c index 4bc71cec..6d44bda7 100644 --- a/src/lib/RunnerRedirect.c +++ b/src/lib/RunnerRedirect.c @@ -12,6 +12,7 @@ #include #include #include +#include static int (*execl_orig)(const char *filename, const char *arg, ...); static int (*execlp_orig)(const char *filename, const char *arg, ...); @@ -50,6 +51,11 @@ __attribute__((constructor)) static void init() _IO_popen_orig = dlsym(RTLD_NEXT, "_IO_popen"); posix_spawn_orig = dlsym(RTLD_NEXT, "posix_spawn"); posix_spawnp_orig = dlsym(RTLD_NEXT, "posix_spawnp"); + + assert(execl_orig != execl); + assert(execv_orig != execv); + assert(execvp_orig != execvp); + assert(execvpe_orig != execvpe); } #define PRINT_CMD() \ @@ -168,7 +174,7 @@ int posix_spawn(pid_t *pid, const char *file, char *const argv[], char *const envp[]) { DECLARE_ARGS(); - return posix_spawn_orig(pid, file, file_actions, attrp, argv, envp); + return posix_spawn_orig(pid, file, file_actions, attrp, args, envp); } int posix_spawnp(pid_t *pid, const char *file, @@ -177,5 +183,5 @@ int posix_spawnp(pid_t *pid, const char *file, char *const argv[], char *const envp[]) { DECLARE_ARGS(); - return posix_spawnp_orig(pid, file, file_actions, attrp, argv, envp); + return posix_spawnp_orig(pid, file, file_actions, attrp, args, envp); }