From dac34b628c767efc3dda187a26a6dfde32882fdb Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Thu, 7 Jul 2022 17:31:09 +0800 Subject: [PATCH] sync from rvi code pull in "Fix unistd.exec_argv0_null for new kernels."(664912dc099ea83c85a9c81c14a2796c685d3460) from rvi upstream. Signed-off-by: Chen Wang --- tests/unistd_test.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp index 7d1e6128b..888c6bb61 100644 --- a/tests/unistd_test.cpp +++ b/tests/unistd_test.cpp @@ -1515,11 +1515,22 @@ TEST(UNISTD_TEST, execvp_libcore_test_55017) { } 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 "" 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* envs[] = {nullptr}; ASSERT_EXIT(execve("/system/bin/run-as", args, envs), testing::ExitedWithCode(1), - ": usage: run-as"); + ": usage: run-as"); } TEST(UNISTD_TEST, fexecve_failure) { -- Gitee