[compiler-rt] 9213202 - [sanitizer] Fix PosixSpawnImpl which fails exitcode test
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 1 21:03:11 PDT 2021
Author: Vitaly Buka
Date: 2021-11-01T21:03:02-07:00
New Revision: 9213202abd275c26c51cc46e2a34c678051bd179
URL: https://github.com/llvm/llvm-project/commit/9213202abd275c26c51cc46e2a34c678051bd179
DIFF: https://github.com/llvm/llvm-project/commit/9213202abd275c26c51cc46e2a34c678051bd179.diff
LOG: [sanitizer] Fix PosixSpawnImpl which fails exitcode test
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/test/sanitizer_common/TestCases/Posix/posix_spawn.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 066f64a393562..d0cb1b4a1dc51 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -2434,11 +2434,11 @@ static int PosixSpawnImpl(void *ctx, RealSpawnPtr *real_posix_spawn, pid_t *pid,
char *const *s = argv;
for (; *s; ++s)
COMMON_INTERCEPTOR_READ_RANGE(ctx, *s, internal_strlen(*s) + 1);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, argv, (s - argv + 1) / sizeof(*s));
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, argv, (s - argv + 1) * sizeof(*s));
s = envp;
for (; *s; ++s)
COMMON_INTERCEPTOR_READ_RANGE(ctx, *s, internal_strlen(*s) + 1);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, s, (s - envp + 1) / sizeof(*s));
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, envp, (s - envp + 1) * sizeof(*s));
int res =
real_posix_spawn(pid, file_or_path, file_actions, attrp, argv, envp);
if (res == 0)
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/posix_spawn.c b/compiler-rt/test/sanitizer_common/TestCases/Posix/posix_spawn.c
index 358d3b4810235..d99fbd52ffcd5 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/posix_spawn.c
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/posix_spawn.c
@@ -1,7 +1,4 @@
// RUN: %clang %s -o %t && %run %t 2>&1 | FileCheck %s
-//
-// Older versions of Android do not have certain posix_spawn* functions.
-// UNSUPPORTED: android
#include <assert.h>
#include <spawn.h>
@@ -16,21 +13,14 @@ int main(int argc, char **argv) {
return 0;
}
- int s;
-
- posix_spawnattr_t attr;
- s = posix_spawnattr_init(&attr);
- assert(!s);
-
- posix_spawn_file_actions_t file_actions;
- s = posix_spawn_file_actions_init(&file_actions);
- assert(!s);
+ posix_spawnattr_t attr = {};
+ posix_spawn_file_actions_t file_actions = {};
char *const args[] = {argv[0], "2", NULL};
char *const env[] = {"A=B", NULL};
pid_t pid;
- s = posix_spawn(&pid, argv[0], &file_actions, &attr, args, env);
+ int s = posix_spawn(&pid, argv[0], &file_actions, &attr, args, env);
assert(!s);
waitpid(pid, &s, WUNTRACED | WCONTINUED);
More information about the llvm-commits
mailing list