Skip to content

Commit dd6f785

Browse files
committed
Assertions + fixes to arguments passed to posix_spawn/spawnp.
1 parent f931703 commit dd6f785

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lib/RunnerRedirect.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <unistd.h>
1313
#include <dlfcn.h>
1414
#include <spawn.h>
15+
#include <assert.h>
1516

1617
static int (*execl_orig)(const char *filename, const char *arg, ...);
1718
static int (*execlp_orig)(const char *filename, const char *arg, ...);
@@ -50,6 +51,11 @@ __attribute__((constructor)) static void init()
5051
_IO_popen_orig = dlsym(RTLD_NEXT, "_IO_popen");
5152
posix_spawn_orig = dlsym(RTLD_NEXT, "posix_spawn");
5253
posix_spawnp_orig = dlsym(RTLD_NEXT, "posix_spawnp");
54+
55+
assert(execl_orig != execl);
56+
assert(execv_orig != execv);
57+
assert(execvp_orig != execvp);
58+
assert(execvpe_orig != execvpe);
5359
}
5460

5561
#define PRINT_CMD() \
@@ -168,7 +174,7 @@ int posix_spawn(pid_t *pid, const char *file,
168174
char *const argv[], char *const envp[])
169175
{
170176
DECLARE_ARGS();
171-
return posix_spawn_orig(pid, file, file_actions, attrp, argv, envp);
177+
return posix_spawn_orig(pid, file, file_actions, attrp, args, envp);
172178
}
173179

174180
int posix_spawnp(pid_t *pid, const char *file,
@@ -177,5 +183,5 @@ int posix_spawnp(pid_t *pid, const char *file,
177183
char *const argv[], char *const envp[])
178184
{
179185
DECLARE_ARGS();
180-
return posix_spawnp_orig(pid, file, file_actions, attrp, argv, envp);
186+
return posix_spawnp_orig(pid, file, file_actions, attrp, args, envp);
181187
}

0 commit comments

Comments
 (0)