From: Paul Floyd Date: Wed, 12 Oct 2022 06:34:51 +0000 (+0200) Subject: Bug 131186 - writev reports error in (vector[...]) X-Git-Tag: VALGRIND_3_20_0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dde5c405b020c96c0595222045475d195939a2b;p=thirdparty%2Fvalgrind.git Bug 131186 - writev reports error in (vector[...]) Use the index rather than ... Also done for readv. --- diff --git a/NEWS b/NEWS index b2ca7e12d7..e6094b5bf2 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,7 @@ bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. +131186 writev reports error in (vector[...]) 434764 iconv_open causes ld.so v2.28+ to use optimised strncmp 446754 Improve error codes from alloc functions under memcheck 452274 memcheck crashes with Assertion 'sci->status.what == SsIdle' failed diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 44a60bf128..7d11ff4064 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -4410,6 +4410,7 @@ PRE(sys_readv) { Int i; struct vki_iovec * vec; + char buf[sizeof("writev(vector[])") + 11]; *flags |= SfMayBlock; PRINT("sys_readv ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); @@ -4424,9 +4425,10 @@ PRE(sys_readv) if (ML_(safe_to_deref)((const void*)ARG2, ARG3*sizeof(struct vki_iovec *))) { vec = (struct vki_iovec *)(Addr)ARG2; - for (i = 0; i < (Int)ARG3; i++) - PRE_MEM_WRITE( "readv(vector[...])", - (Addr)vec[i].iov_base, vec[i].iov_len ); + for (i = 0; i < (Int)ARG3; i++) { + VG_(sprintf)(buf, "writev(vector[%d])", i); + PRE_MEM_WRITE(buf, (Addr)vec[i].iov_base, vec[i].iov_len ); + } } } } @@ -4770,6 +4772,7 @@ PRE(sys_writev) { Int i; struct vki_iovec * vec; + char buf[sizeof("writev(vector[])") + 11]; *flags |= SfMayBlock; PRINT("sys_writev ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); @@ -4785,9 +4788,10 @@ PRE(sys_writev) if (ML_(safe_to_deref)((const void*)ARG2, ARG3*sizeof(struct vki_iovec *))) { vec = (struct vki_iovec *)(Addr)ARG2; - for (i = 0; i < (Int)ARG3; i++) - PRE_MEM_READ( "writev(vector[...])", - (Addr)vec[i].iov_base, vec[i].iov_len ); + for (i = 0; i < (Int)ARG3; i++) { + VG_(sprintf)(buf, "writev(vector[%d])", i); + PRE_MEM_READ( buf, (Addr)vec[i].iov_base, vec[i].iov_len ); + } } } } diff --git a/memcheck/tests/writev1.stderr.exp b/memcheck/tests/writev1.stderr.exp index aea8390c74..df9ef77116 100644 --- a/memcheck/tests/writev1.stderr.exp +++ b/memcheck/tests/writev1.stderr.exp @@ -1,5 +1,5 @@ Test file created. -Syscall param writev(vector[...]) points to unaddressable byte(s) +Syscall param writev(vector[0]) points to unaddressable byte(s) ... by 0x........: main (writev1.c:56) Address 0x........ is not stack'd, malloc'd or (recently) free'd diff --git a/memcheck/tests/writev1.stderr.exp-solaris b/memcheck/tests/writev1.stderr.exp-solaris index b19d775c50..1cc95e7710 100644 --- a/memcheck/tests/writev1.stderr.exp-solaris +++ b/memcheck/tests/writev1.stderr.exp-solaris @@ -1,5 +1,5 @@ Test file created. -Syscall param writev(vector[...]) points to unaddressable byte(s) +Syscall param writev(vector[0]) points to unaddressable byte(s) ... by 0x........: main (writev1.c:56) Address 0x........ is not stack'd, malloc'd or (recently) free'd