|
From: <sv...@va...> - 2015-04-25 18:14:24
|
Author: florian
Date: Sat Apr 25 19:14:17 2015
New Revision: 15143
Log:
Fix the writev / readv wrappers. Do not read the array pointed to
by the 2nd argument, if the element count is negative.
Modified:
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/memcheck/tests/writev1.c
trunk/memcheck/tests/writev1.stderr.exp
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-generic.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c Sat Apr 25 19:14:17 2015
@@ -4006,7 +4006,8 @@
if (!ML_(fd_allowed)(ARG1, "readv", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
} else {
- PRE_MEM_READ( "readv(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) );
+ if ((Int)ARG3 >= 0)
+ PRE_MEM_READ( "readv(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) );
if (ARG2 != 0) {
/* ToDo: don't do any of the following if the vector is invalid */
@@ -4335,8 +4336,9 @@
if (!ML_(fd_allowed)(ARG1, "writev", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
} else {
- PRE_MEM_READ( "writev(vector)",
- ARG2, ARG3 * sizeof(struct vki_iovec) );
+ if ((Int)ARG3 >= 0)
+ PRE_MEM_READ( "writev(vector)",
+ ARG2, ARG3 * sizeof(struct vki_iovec) );
if (ARG2 != 0) {
/* ToDo: don't do any of the following if the vector is invalid */
vec = (struct vki_iovec *)ARG2;
Modified: trunk/memcheck/tests/writev1.c
==============================================================================
--- trunk/memcheck/tests/writev1.c (original)
+++ trunk/memcheck/tests/writev1.c Sat Apr 25 19:14:17 2015
@@ -80,7 +80,7 @@
fprintf(stderr, "expected errno = EINVAL, got %d\n", errno);
}
else
- fprintf(stderr, "Error writev returned a positive value\n");
+ fprintf(stderr, "Error readv returned a positive value\n");
unlink(f_name);
Modified: trunk/memcheck/tests/writev1.stderr.exp
==============================================================================
--- trunk/memcheck/tests/writev1.stderr.exp (original)
+++ trunk/memcheck/tests/writev1.stderr.exp Sat Apr 25 19:14:17 2015
@@ -5,15 +5,5 @@
Address 0x........ is not stack'd, malloc'd or (recently) free'd
Received EFAULT as expected
-Syscall param writev(vector) points to unaddressable byte(s)
- ...
- by 0x........: main (writev1.c:68)
- Address 0x........ is not stack'd, malloc'd or (recently) free'd
-
Received EINVAL as expected
-Syscall param readv(vector) points to unaddressable byte(s)
- ...
- by 0x........: main (writev1.c:76)
- Address 0x........ is not stack'd, malloc'd or (recently) free'd
-
Received EINVAL as expected
|