]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix the writev / readv wrappers. Do not read the array pointed to
authorFlorian Krohm <florian@eich-krohm.de>
Sat, 25 Apr 2015 18:14:17 +0000 (18:14 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sat, 25 Apr 2015 18:14:17 +0000 (18:14 +0000)
by the 2nd argument, if the element count is negative.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15143

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

index cb3cfb1aac2bc89621e121e5124f563e0c71a707..2fd37d1cbe65e5f9e3ed5652019f071af1689e1a 100644 (file)
@@ -4006,7 +4006,8 @@ PRE(sys_readv)
    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 @@ PRE(sys_writev)
    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;
index 82ad47f9ba8d25bc499e0c2a289fa7e8fdfd22ef..6a8c281c898cbe6968bac4eacdf61c79a2b83a03 100644 (file)
@@ -80,7 +80,7 @@ int main(void)
                        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);
         
index 6063a3805f041ed38e983c0489328bbc4b9c81cd..0fe62eecb7b835f13d8f24b60c8eacefe4365680 100644 (file)
@@ -5,15 +5,5 @@ Syscall param writev(vector[...]) points to unaddressable byte(s)
  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