From e816f4c44f8556a8e3a64ce972e46acf62d5f89d Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Sun, 3 Apr 2022 22:00:09 +0200 Subject: [PATCH] Fixes for memcheck/tests/freebsd/realpathat The syscall to realpathat was missing the buffer size argument. By luck, no problem on amd64 but this failed on x86. This adds the argument and a filter for the errors (size_t can be 4 or 8 bytes) --- memcheck/tests/freebsd/Makefile.am | 2 +- memcheck/tests/freebsd/filter_realpathat | 7 ++ memcheck/tests/freebsd/realpathat.c | 2 + memcheck/tests/freebsd/realpathat.stderr.exp | 92 +++++++++++--------- memcheck/tests/freebsd/realpathat.vgtest | 1 + 5 files changed, 60 insertions(+), 44 deletions(-) create mode 100755 memcheck/tests/freebsd/filter_realpathat diff --git a/memcheck/tests/freebsd/Makefile.am b/memcheck/tests/freebsd/Makefile.am index 66d1022753..f70e822a41 100644 --- a/memcheck/tests/freebsd/Makefile.am +++ b/memcheck/tests/freebsd/Makefile.am @@ -2,7 +2,7 @@ include $(top_srcdir)/Makefile.tool-tests.am dist_noinst_SCRIPTS = filter_stderr filter_pts dump_stdout filter_sigwait \ - filter_scalar + filter_scalar filter_realpathat EXTRA_DIST = \ scalar.h \ diff --git a/memcheck/tests/freebsd/filter_realpathat b/memcheck/tests/freebsd/filter_realpathat new file mode 100755 index 0000000000..82b21841dd --- /dev/null +++ b/memcheck/tests/freebsd/filter_realpathat @@ -0,0 +1,7 @@ +#! /bin/sh + +gsed 's/Invalid write of size 8/Invalid write of size .../' | + +../filter_stderr "$@" + +exit 0 diff --git a/memcheck/tests/freebsd/realpathat.c b/memcheck/tests/freebsd/realpathat.c index 218fd75cb2..d7a84240b0 100644 --- a/memcheck/tests/freebsd/realpathat.c +++ b/memcheck/tests/freebsd/realpathat.c @@ -15,8 +15,10 @@ int main(void) // bad int * bad_int1 = malloc(sizeof(char)); int * bad_int2 = malloc(sizeof(char)); + size_t * bad_sz = malloc(sizeof(char)); *bad_int1 = AT_FDCWD; *bad_int2 = 0; + *bad_sz = PATH_MAX; syscall(SYS___realpathat, *bad_int1, self_path, buf, *bad_int2); free(bad_int1); free(bad_int2); diff --git a/memcheck/tests/freebsd/realpathat.stderr.exp b/memcheck/tests/freebsd/realpathat.stderr.exp index 575f1e6a98..3d6647e3ae 100644 --- a/memcheck/tests/freebsd/realpathat.stderr.exp +++ b/memcheck/tests/freebsd/realpathat.stderr.exp @@ -1,162 +1,168 @@ Invalid write of size 4 - at 0x........: main (realpathat.c:18) + at 0x........: main (realpathat.c:19) Address 0x........ is 0 bytes inside a block of size 1 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (realpathat.c:16) Invalid write of size 4 - at 0x........: main (realpathat.c:19) + at 0x........: main (realpathat.c:20) Address 0x........ is 0 bytes inside a block of size 1 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (realpathat.c:17) +Invalid write of size ... + at 0x........: main (realpathat.c:21) + Address 0x........ is 0 bytes inside a block of size 1 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (realpathat.c:18) + Syscall param __realpathat(fd) contains uninitialised byte(s) ... - by 0x........: main (realpathat.c:20) + by 0x........: main (realpathat.c:22) Syscall param __realpathat(size) contains uninitialised byte(s) ... - by 0x........: main (realpathat.c:20) + by 0x........: main (realpathat.c:22) Invalid read of size 1 ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 0 bytes inside a block of size 31 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:28) + by 0x........: main (realpathat.c:30) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) ... - by 0x........: main (realpathat.c:26) + by 0x........: main (realpathat.c:28) Syscall param __realpathat(path) points to unaddressable byte(s) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 0 bytes inside a block of size 31 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:28) + by 0x........: main (realpathat.c:30) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) ... - by 0x........: main (realpathat.c:26) + by 0x........: main (realpathat.c:28) Syscall param __realpathat(buf) points to unaddressable byte(s) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 0 bytes inside a block of size 100 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:27) + by 0x........: main (realpathat.c:29) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:25) + by 0x........: main (realpathat.c:27) Invalid read of size 1 ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 0 bytes inside a block of size 31 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:28) + by 0x........: main (realpathat.c:30) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) ... - by 0x........: main (realpathat.c:26) + by 0x........: main (realpathat.c:28) Syscall param __getcwd(buf) points to unaddressable byte(s) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 0 bytes inside a block of size 100 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:27) + by 0x........: main (realpathat.c:29) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:25) + by 0x........: main (realpathat.c:27) Invalid read of size 1 at 0x........: strlcpy (vg_replace_strmem.c:...) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 0 bytes inside a block of size 31 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:28) + by 0x........: main (realpathat.c:30) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) ... - by 0x........: main (realpathat.c:26) + by 0x........: main (realpathat.c:28) Invalid read of size 1 at 0x........: strlcpy (vg_replace_strmem.c:...) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 1 bytes inside a block of size 31 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:28) + by 0x........: main (realpathat.c:30) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) ... - by 0x........: main (realpathat.c:26) + by 0x........: main (realpathat.c:28) Invalid read of size 1 at 0x........: strlcpy (vg_replace_strmem.c:...) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 30 bytes inside a block of size 31 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:28) + by 0x........: main (realpathat.c:30) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) ... - by 0x........: main (realpathat.c:26) + by 0x........: main (realpathat.c:28) Invalid write of size 2 ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 55 bytes inside a block of size 100 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:27) + by 0x........: main (realpathat.c:29) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:25) + by 0x........: main (realpathat.c:27) Invalid read of size 1 at 0x........: strlcat (vg_replace_strmem.c:...) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 56 bytes inside a block of size 100 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:27) + by 0x........: main (realpathat.c:29) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:25) + by 0x........: main (realpathat.c:27) Invalid write of size 1 at 0x........: strlcat (vg_replace_strmem.c:...) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 56 bytes inside a block of size 100 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:27) + by 0x........: main (realpathat.c:29) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:25) + by 0x........: main (realpathat.c:27) Invalid write of size 1 at 0x........: strlcat (vg_replace_strmem.c:...) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 66 bytes inside a block of size 100 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:27) + by 0x........: main (realpathat.c:29) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:25) + by 0x........: main (realpathat.c:27) Syscall param fstatat(path) points to unaddressable byte(s) ... - by 0x........: main (realpathat.c:30) + by 0x........: main (realpathat.c:32) Address 0x........ is 56 bytes inside a block of size 100 free'd at 0x........: free (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:27) + by 0x........: main (realpathat.c:29) Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (realpathat.c:25) + by 0x........: main (realpathat.c:27) diff --git a/memcheck/tests/freebsd/realpathat.vgtest b/memcheck/tests/freebsd/realpathat.vgtest index 9efbcbdfcf..c34ca564aa 100644 --- a/memcheck/tests/freebsd/realpathat.vgtest +++ b/memcheck/tests/freebsd/realpathat.vgtest @@ -1,3 +1,4 @@ prog: realpathat prereq: test -e ./realpathat vgopts: -q +stderr_filter: filter_realpathat -- 2.47.2