]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fixes for memcheck/tests/freebsd/realpathat
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 3 Apr 2022 20:00:09 +0000 (22:00 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 3 Apr 2022 20:00:09 +0000 (22:00 +0200)
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
memcheck/tests/freebsd/filter_realpathat [new file with mode: 0755]
memcheck/tests/freebsd/realpathat.c
memcheck/tests/freebsd/realpathat.stderr.exp
memcheck/tests/freebsd/realpathat.vgtest

index 66d1022753a5cf42864d47734e3f01b40de09a5a..f70e822a415888b0612fe013215ab4839a7c6177 100644 (file)
@@ -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 (executable)
index 0000000..82b2184
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+gsed 's/Invalid write of size 8/Invalid write of size .../' |
+
+../filter_stderr "$@"
+
+exit 0
index 218fd75cb296a39db3454a00f50b69faf603279f..d7a84240b0a67dce7fb86295df053c6f14e5568e 100644 (file)
@@ -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);
index 575f1e6a980b8b209e9df486e1a7cf0d1e9af7e9..3d6647e3aebeea62d14d82a411931855228a2487 100644 (file)
 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)
 
index 9efbcbdfcfc5877b4d8ef3bfcf63ee85bc4a8f42..c34ca564aa1e3ad2072b29bd8d56b5f34c0dece6 100644 (file)
@@ -1,3 +1,4 @@
 prog: realpathat
 prereq: test -e ./realpathat
 vgopts: -q
+stderr_filter: filter_realpathat