From f87c58e89c4a0e85c59f39a7ae01027686bfff73 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Sun, 23 Mar 2025 10:21:29 +0100 Subject: [PATCH] Bug 501893 - Missing suppression for __wcscat_avx2 (strcat-strlen-avx2.h.S:68)? --- .gitignore | 1 + NEWS | 1 + memcheck/tests/Makefile.am | 2 ++ memcheck/tests/wcpncpy.stderr.exp | 8 ++++---- memcheck/tests/wcscat.c | 20 ++++++++++++++++++++ memcheck/tests/wcscat.stderr.exp | 0 memcheck/tests/wcscat.stdout.exp | 1 + memcheck/tests/wcscat.vgtest | 2 ++ shared/vg_replace_strmem.c | 29 +++++++++++++++++++++++++++++ 9 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 memcheck/tests/wcscat.c create mode 100644 memcheck/tests/wcscat.stderr.exp create mode 100644 memcheck/tests/wcscat.stdout.exp create mode 100644 memcheck/tests/wcscat.vgtest diff --git a/.gitignore b/.gitignore index 45290719a6..d64b9fab74 100644 --- a/.gitignore +++ b/.gitignore @@ -1045,6 +1045,7 @@ /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 d42a5f479a..e4e6769ba8 100644 --- 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 diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 8a5e0e1f72..bdaa9d761e 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -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 \ diff --git a/memcheck/tests/wcpncpy.stderr.exp b/memcheck/tests/wcpncpy.stderr.exp index abe23b7730..0ff9e5c741 100644 --- a/memcheck/tests/wcpncpy.stderr.exp +++ b/memcheck/tests/wcpncpy.stderr.exp @@ -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 index 0000000000..bf3ec70c6d --- /dev/null +++ b/memcheck/tests/wcscat.c @@ -0,0 +1,20 @@ +// See https://bugs.kde.org/show_bug.cgi?id=501893 +#include +#include +#include +#include + +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 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/wcscat.stdout.exp b/memcheck/tests/wcscat.stdout.exp new file mode 100644 index 0000000000..b5b8c09e53 --- /dev/null +++ b/memcheck/tests/wcscat.stdout.exp @@ -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 index 0000000000..30b25d0efc --- /dev/null +++ b/memcheck/tests/wcscat.vgtest @@ -0,0 +1,2 @@ +prog: wcscat +vgopts: -q diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index ae13a2a5f8..71f15c85fb 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -108,6 +108,7 @@ 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 ---*/ -- 2.39.5