Skip to content

Commit

Permalink
test_mx_util: Call mx_call_external with argv != NULL
Browse files Browse the repository at this point in the history
Newer Valgrind versions complain, when `execv()` is called with
argv==NULL or with argv[0]==NULL.

argv == NULL is not allowed by Posix, but the Linux kernel transforms
that into an empty argument list. An empty argument list with
argv[0]==NULL does not go against any specs, altough it might confuse
programms and led to pkexec being exploitable (CVE-2021-4034)

It is not wrong on Linux to call execv() or a wrapper function with
argv==NULL, but avoid it anyway to prevent Valgrind warnings.
  • Loading branch information
donald committed Jan 10, 2024
1 parent 0321629 commit 8d7d397
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test_mx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,13 @@ static void test_mx_call_external(void) {
int sts;
errno = 999;

sts = mx_call_external("/usr/bin/true", NULL);
char *argv[] = { "", NULL };

sts = mx_call_external("/usr/bin/true", argv);
assert(sts == 0);
assert(errno == 999);

sts = mx_call_external("/usr/bin/false", NULL);
sts = mx_call_external("/usr/bin/false", argv);
assert(sts == -1);
assert(errno == EPROTO);
}
Expand Down

0 comments on commit 8d7d397

Please sign in to comment.