]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 131186 - writev reports error in (vector[...])
authorPaul Floyd <pjfloyd@wanadoo.fr>
Wed, 12 Oct 2022 06:34:51 +0000 (08:34 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Wed, 12 Oct 2022 06:34:51 +0000 (08:34 +0200)
Use the index rather than ...
Also done for readv.

NEWS
coregrind/m_syswrap/syswrap-generic.c
memcheck/tests/writev1.stderr.exp
memcheck/tests/writev1.stderr.exp-solaris

diff --git a/NEWS b/NEWS
index b2ca7e12d7f32ca78caeefc996d0db2903289f66..e6094b5bf23593cf156e0842cbbc60e5d1ba2027 100644 (file)
--- 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
index 44a60bf12828eb4c8fdc4e30ad8088346d78a92a..7d11ff4064ebf1063d3d91e6737bd142282aa2bf 100644 (file)
@@ -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 );
+         }
       }
    }
 }
index aea8390c74a3663c4f921b3985d44c3041b3281f..df9ef77116f90eb3ea23e9181fb069f205f9855b 100644 (file)
@@ -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
index b19d775c5001c5c2f64aee2ddae1940d8b89a684..1cc95e7710641d9c85dae4d4638b87940a8afe35 100644 (file)
@@ -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