Bug 131186 - writev reports error in (vector[...])

Use the index rather than ...
Also done for readv.
This commit is contained in:
Paul Floyd 2022-10-12 08:34:51 +02:00
parent 3c57204534
commit 2dde5c405b
4 changed files with 13 additions and 8 deletions

1
NEWS
View File

@ -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

View 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 );
}
}
}
}

View 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

View 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