]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 501893 - Missing suppression for __wcscat_avx2 (strcat-strlen-avx2.h.S:68)?
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 23 Mar 2025 09:21:29 +0000 (10:21 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 23 Mar 2025 09:21:29 +0000 (10:21 +0100)
.gitignore
NEWS
memcheck/tests/Makefile.am
memcheck/tests/wcpncpy.stderr.exp
memcheck/tests/wcscat.c [new file with mode: 0644]
memcheck/tests/wcscat.stderr.exp [new file with mode: 0644]
memcheck/tests/wcscat.stdout.exp [new file with mode: 0644]
memcheck/tests/wcscat.vgtest [new file with mode: 0644]
shared/vg_replace_strmem.c

index 45290719a6bce52c00a97657656bb8800b3dcf73..d64b9fab743677f865d08ffa534d3ca5909b27f5 100644 (file)
 /memcheck/tests/vcpu_fnfns
 /memcheck/tests/vgtest_ume
 /memcheck/tests/wcs
+/memcheck/tests/wcscat
 /memcheck/tests/weirdioctl
 /memcheck/tests/with space
 /memcheck/tests/wcpncpy
diff --git a/NEWS b/NEWS
index d42a5f479a17155a76779f97bb4a29465f9f2e85..e4e6769ba8c182e8cea177d3dc9f9409d69fcf8a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 501365  syscall userfaultfd not wrapped
 501846  Add x86 Linux shm wrappers
 501850  FreeBSD syscall arguments 7 and 8 incorrect.
+501893  Missing suppression for __wcscat_avx2 (strcat-strlen-avx2.h.S:68)?
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 8a5e0e1f7226001230b888c058358897f5679b9d..bdaa9d761e6122a41665d121f7234bcf8f343cee 100644 (file)
@@ -450,6 +450,7 @@ EXTRA_DIST = \
        vcpu_fnfns.stderr.exp vcpu_fnfns.vgtest \
        wcpncpy.stderr.exp wcpncpy.vgtest \
        wcs.vgtest wcs.stderr.exp wcs.stdout.exp \
+       wcscat.vgtest wcscat.stderr.exp wcscat.stdout.exp \
        wcsncpy.vgtest wcsncpy.stderr.exp \
        wmemcmp.vgtest wmemcmp.stderr.exp \
        wrap1.vgtest wrap1.stdout.exp wrap1.stderr.exp \
@@ -556,6 +557,7 @@ check_PROGRAMS = \
        varinforestrict \
        vcpu_fbench vcpu_fnfns \
        wcs \
+       wcscat \
        xml1 \
        wmemcmp \
        wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 \
index abe23b7730e12cfa821252e987c2e9d0fd8322c7..0ff9e5c7417cd960eacd6e55c3052044e4134a18 100644 (file)
@@ -1,19 +1,19 @@
 Conditional jump or move depends on uninitialised value(s)
-   at 0x........: wcpncpy (vg_replace_strmem.c:2426)
+   at 0x........: wcpncpy (vg_replace_strmem.c:2427)
    by 0x........: main (wcpncpy.c:14)
 
 Invalid write of size 4
-   at 0x........: wcpncpy (vg_replace_strmem.c:2426)
+   at 0x........: wcpncpy (vg_replace_strmem.c:2427)
    by 0x........: main (wcpncpy.c:27)
  Address 0x........ is 20 bytes inside a block of size 22 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
    by 0x........: main (wcpncpy.c:10)
 
 Source and destination overlap in wcpncpy(0x........, 0x........)
-   at 0x........: wcpncpy (vg_replace_strmem.c:2426)
+   at 0x........: wcpncpy (vg_replace_strmem.c:2427)
    by 0x........: main (wcpncpy.c:35)
 
 Source and destination overlap in wcpncpy(0x........, 0x........)
-   at 0x........: wcpncpy (vg_replace_strmem.c:2426)
+   at 0x........: wcpncpy (vg_replace_strmem.c:2427)
    by 0x........: main (wcpncpy.c:43)
 
diff --git a/memcheck/tests/wcscat.c b/memcheck/tests/wcscat.c
new file mode 100644 (file)
index 0000000..bf3ec70
--- /dev/null
@@ -0,0 +1,20 @@
+// See https://bugs.kde.org/show_bug.cgi?id=501893
+#include <wchar.h>
+#include <stdio.h>
+#include <locale.h>
+#include <stdlib.h>
+
+int main(void)
+{
+    wchar_t* str = malloc(sizeof(L"/usr/lib/python310.zip:/usr/lib/python3.10:"));
+    wchar_t* add1 = wcsdup(L"/usr/lib/python310.zip:/usr/lib/python3.10");
+    wchar_t* add2 = wcsdup(L":");
+    str[0] = 0;
+    wcscat(str, add1);
+    wcscat(str, add2);
+    setlocale(LC_ALL, "en_US.utf8");
+    printf("%ls\n", str);
+    free(str);
+    free(add1);
+    free(add2);
+}
diff --git a/memcheck/tests/wcscat.stderr.exp b/memcheck/tests/wcscat.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/wcscat.stdout.exp b/memcheck/tests/wcscat.stdout.exp
new file mode 100644 (file)
index 0000000..b5b8c09
--- /dev/null
@@ -0,0 +1 @@
+/usr/lib/python310.zip:/usr/lib/python3.10:
diff --git a/memcheck/tests/wcscat.vgtest b/memcheck/tests/wcscat.vgtest
new file mode 100644 (file)
index 0000000..30b25d0
--- /dev/null
@@ -0,0 +1,2 @@
+prog: wcscat
+vgopts: -q
index ae13a2a5f87a34e704e2ceec35a2c712f7248141..71f15c85fb71fc05a1f8f91eb66e3156e19b6584 100644 (file)
    20480 WCSNCPY
    20490 MEMCCPY
    20500 WCPNCPY
+   20510 WCSCAT
 */
 
 #if defined(VGO_solaris)
@@ -2426,6 +2427,34 @@ static inline void my_exit ( int x )
  WCPNCPY(VG_Z_LIBC_SONAME, wcpncpy)
 #endif
 
+/*----------------------- wcscat ----------------------*/
+
+#define WCSCAT(soname, fnname) \
+ Int* VG_REPLACE_FUNCTION_EZU(20510,soname,fnname) \
+    ( Int *restrict dest, const Int *restrict src ); \
+    Int* VG_REPLACE_FUNCTION_EZU(20510,soname,fnname) \
+    ( Int *restrict dest, const Int *restrict src ) \
+ { \
+    const Int* src_orig = src; \
+    Int* dest_orig = dest; \
+    while (*dest) dest++; \
+    while (*src) *dest++ = *src++; \
+    *dest = 0; \
+      \
+    /* This is a bit redundant, I think;  any overlap and the wcscat will */ \
+    /* go forever... or until a seg fault occurs. */ \
+    if (is_overlap(dest_orig,  \
+                   src_orig,  \
+                  (Addr)dest-(Addr)dest_orig+1,  \
+                  (Addr)src-(Addr)src_orig+1)) \
+    RECORD_OVERLAP_ERROR("wcscat", dest_orig, src_orig, 0); \
+      \
+    return dest_orig; \
+ }
+
+#if defined(VGO_linux)
+ WCSCAT(VG_Z_LIBC_SONAME, __wcscat_avx2)
+#endif
 
 /*------------------------------------------------------------*/
 /*--- Improve definedness checking of process environment  ---*/