Skip to content

Commit

Permalink
Fix unistd.exec_argv0_null for new kernels.
Browse files Browse the repository at this point in the history
There are other options here (see the code comment for details), but
this is the least effort/least disruptive for now.

Bug: 228898932, 227498625
Test: treehugger
Change-Id: I33be6fbfc022238de2f1846a69af1e712a9d6391
(cherry picked from commit bb1cc5a)
  • Loading branch information
enh-google authored and adelva1984 committed Apr 27, 2022
1 parent d8fa0f6 commit 478e637
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/unistd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,11 +1515,21 @@ 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 "<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* envs[] = {nullptr};
ASSERT_EXIT(execve("/system/bin/run-as", args, envs), testing::ExitedWithCode(1),
"<unknown>: usage: run-as");
": usage: run-as");
}

TEST(UNISTD_TEST, fexecve_failure) {
Expand Down

0 comments on commit 478e637

Please sign in to comment.