execve: fix support of personalities with different word size

* execve.c (printargc): Do not assume that host and target pointers have
the same size.
* tests/execve.c: New file.
* tests/execve.expected: Likewise.
* tests/execve-v.expected: Likewise.
* tests/execve.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add execve.
(TESTS): Add execve.test.
(EXTRA_DIST): Add execve.expected and execve-v.expected.
* tests/.gitignore: Add execve.
This commit is contained in:
Дмитрий Левин 2015-07-27 10:02:33 +00:00
parent ddb53dd142
commit 4ff687bb31
7 changed files with 37 additions and 3 deletions

View File

@ -32,10 +32,10 @@ static void
printargc(const char *fmt, struct tcb *tcp, long addr)
{
int count;
char *cp;
char *cp = NULL;
for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
addr += sizeof(char *);
for (count = 0; !umoven(tcp, addr, current_wordsize, &cp) && cp; count++) {
addr += current_wordsize;
}
tprintf(fmt, count, count == 1 ? "" : "s");
}

1
tests/.gitignore vendored
View File

@ -1,5 +1,6 @@
bpf
caps
execve
fanotify_mark
filter-unavailable
getrandom

View File

@ -11,6 +11,7 @@ AM_CPPFLAGS = -I$(top_builddir)/$(OS)/$(ARCH) \
check_PROGRAMS = \
bpf \
caps \
execve \
fanotify_mark \
filter-unavailable \
getrandom \
@ -65,6 +66,7 @@ TESTS = \
bpf.test \
caps.test \
dumpio.test \
execve.test \
fanotify_mark.test \
filter-unavailable.test \
getdents.test \
@ -117,6 +119,8 @@ AM_TEST_LOG_FLAGS = STRACE_ARCH=$(ARCH) $(srcdir)/run.sh
EXTRA_DIST = init.sh run.sh match.awk \
caps.awk \
dumpio.expected \
execve.expected \
execve-v.expected \
fanotify_mark.expected \
filter-unavailable.expected \
getdents.awk \

1
tests/execve-v.expected Normal file
View File

@ -0,0 +1 @@
execve\("execve\\nfilename", \["execve\\nfilename", "first", "second"\], \["foobar=1", "foo\\nbar=2"\]\) += -1 ENOENT .*

14
tests/execve.c Normal file
View File

@ -0,0 +1,14 @@
#include <unistd.h>
#define FILENAME "execve\nfilename"
static const char * const argv[] =
{ FILENAME, "first", "second", NULL, NULL, NULL };
static const char * const envp[] =
{ "foobar=1", "foo\nbar=2", NULL , "", NULL , "", NULL, NULL};
int
main(void)
{
execve(FILENAME, (char * const *) argv, (char * const *) envp);
return 0;
}

1
tests/execve.expected Normal file
View File

@ -0,0 +1 @@
execve\("execve\\nfilename", \["execve\\nfilename", "first", "second"\], \[/\* 2 vars \*/\]\) += -1 ENOENT .*

13
tests/execve.test Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# Check execve syscall decoding.
. "${srcdir=.}/init.sh"
run_prog
run_strace $args
match_grep
run_strace -v $args
match_grep "$LOG" "$srcdir/${ME_%.test}-v.expected"
exit 0