@@ -2422,6 +2422,54 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags,
2422
2422
#define INIT_GLOB64
2423
2423
#endif // SANITIZER_INTERCEPT_GLOB64
2424
2424
2425
+ #if SANITIZER_INTERCEPT_POSIX_SPAWN
2426
+
2427
+ template <class RealSpawnPtr >
2428
+ static int PosixSpawnImpl (void *ctx, RealSpawnPtr *real_posix_spawn, pid_t *pid,
2429
+ const char *file_or_path, const void *file_actions,
2430
+ const void *attrp, char *const argv[],
2431
+ char *const envp[]) {
2432
+ COMMON_INTERCEPTOR_READ_RANGE (ctx, file_or_path,
2433
+ internal_strlen (file_or_path) + 1 );
2434
+ char *const *s = argv;
2435
+ for (; *s; ++s)
2436
+ COMMON_INTERCEPTOR_READ_RANGE (ctx, *s, internal_strlen (*s) + 1 );
2437
+ COMMON_INTERCEPTOR_READ_RANGE (ctx, argv, (s - argv + 1 ) / sizeof (*s));
2438
+ s = envp;
2439
+ for (; *s; ++s)
2440
+ COMMON_INTERCEPTOR_READ_RANGE (ctx, *s, internal_strlen (*s) + 1 );
2441
+ COMMON_INTERCEPTOR_READ_RANGE (ctx, s, (s - envp + 1 ) / sizeof (*s));
2442
+ int res =
2443
+ real_posix_spawn (pid, file_or_path, file_actions, attrp, argv, envp);
2444
+ if (res == 0 )
2445
+ COMMON_INTERCEPTOR_WRITE_RANGE (ctx, pid, sizeof (*pid));
2446
+ return res;
2447
+ }
2448
+ INTERCEPTOR (int , posix_spawn, pid_t *pid, const char *path,
2449
+ const void *file_actions, const void *attrp, char *const argv[],
2450
+ char *const envp[]) {
2451
+ void *ctx;
2452
+ COMMON_INTERCEPTOR_ENTER (ctx, posix_spawn, pid, path, file_actions, attrp,
2453
+ argv, envp);
2454
+ return PosixSpawnImpl (ctx, REAL (posix_spawn), pid, path, file_actions, attrp,
2455
+ argv, envp);
2456
+ }
2457
+ INTERCEPTOR (int , posix_spawnp, pid_t *pid, const char *file,
2458
+ const void *file_actions, const void *attrp, char *const argv[],
2459
+ char *const envp[]) {
2460
+ void *ctx;
2461
+ COMMON_INTERCEPTOR_ENTER (ctx, posix_spawnp, pid, file, file_actions, attrp,
2462
+ argv, envp);
2463
+ return PosixSpawnImpl (ctx, REAL (posix_spawnp), pid, file, file_actions, attrp,
2464
+ argv, envp);
2465
+ }
2466
+ # define INIT_POSIX_SPAWN \
2467
+ COMMON_INTERCEPT_FUNCTION (posix_spawn); \
2468
+ COMMON_INTERCEPT_FUNCTION (posix_spawnp);
2469
+ #else // SANITIZER_INTERCEPT_POSIX_SPAWN
2470
+ # define INIT_POSIX_SPAWN
2471
+ #endif // SANITIZER_INTERCEPT_POSIX_SPAWN
2472
+
2425
2473
#if SANITIZER_INTERCEPT_WAIT
2426
2474
// According to sys/wait.h, wait(), waitid(), waitpid() may have symbol version
2427
2475
// suffixes on Darwin. See the declaration of INTERCEPTOR_WITH_SUFFIX for
@@ -10229,6 +10277,7 @@ static void InitializeCommonInterceptors() {
10229
10277
INIT_TIME;
10230
10278
INIT_GLOB;
10231
10279
INIT_GLOB64;
10280
+ INIT_POSIX_SPAWN;
10232
10281
INIT_WAIT;
10233
10282
INIT_WAIT4;
10234
10283
INIT_INET;
0 commit comments