Merge "Merge "Fix unistd.exec_argv0_null for new kernels." into android10-tests-dev am: 16457fd9d0" into android11-tests-dev am: ede618aef2

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2078358

Change-Id: I716eacb116e3a4a29acd1aa10ad96f43c583b56b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Automerger Merge Worker 2022-04-27 18:44:30 +00:00
commit 1627acb5e4
1 changed files with 12 additions and 2 deletions

View File

@ -1515,11 +1515,21 @@ TEST(UNISTD_TEST, execvp_libcore_test_55017) {
} }
TEST(UNISTD_TEST, exec_argv0_null) { TEST(UNISTD_TEST, exec_argv0_null) {
// http://b/33276926 // http://b/33276926 and http://b/227498625.
//
// With old kernels, bionic will see the null pointer and use "<unknown>" but
// with new (5.18+) kernels, the kernel will already have substituted the
// empty string, so we don't make any assertion here about what (if anything)
// comes before the first ':'.
//
// If this ever causes trouble, we could change bionic to replace _either_ the
// null pointer or the empty string. We could also use the actual name from
// readlink() on /proc/self/exe if we ever had reason to disallow programs
// from trying to hide like this.
char* args[] = {nullptr}; char* args[] = {nullptr};
char* envs[] = {nullptr}; char* envs[] = {nullptr};
ASSERT_EXIT(execve("/system/bin/run-as", args, envs), testing::ExitedWithCode(1), ASSERT_EXIT(execve("/system/bin/run-as", args, envs), testing::ExitedWithCode(1),
"<unknown>: usage: run-as"); ": usage: run-as");
} }
TEST(UNISTD_TEST, fexecve_failure) { TEST(UNISTD_TEST, fexecve_failure) {