]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fixed readv() and writev() so they won't fall over if they are given a negative
authorNicholas Nethercote <njn@valgrind.org>
Thu, 4 Sep 2003 21:57:45 +0000 (21:57 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Thu, 4 Sep 2003 21:57:45 +0000 (21:57 +0000)
count.  Added a regression test for it.

Updated the basic test stderr filter to strip out line numbers from
vg_intercept.c

MERGE TO STABLE

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

coregrind/vg_syscalls.c
memcheck/tests/Makefile.am
tests/filter_stderr_basic

index 01b8f08ab194075c5667278a239b85c0e44a7d5b..681fe11edb703a50ff5d41e320f4d5b69ce855d1 100644 (file)
@@ -2741,14 +2741,14 @@ void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid )
 
       case __NR_readv: { /* syscall 145 */
          /* int readv(int fd, const struct iovec * vector, size_t count); */
-         UInt i;
+         Int i;
          struct iovec * vec;
          MAYBE_PRINTF("readv ( %d, %p, %d )\n",arg1,arg2,arg3);
          SYSCALL_TRACK( pre_mem_read, tid, "readv(vector)", 
                            arg2, arg3 * sizeof(struct iovec) );
          /* ToDo: don't do any of the following if the vector is invalid */
          vec = (struct iovec *)arg2;
-         for (i = 0; i < arg3; i++)
+         for (i = 0; i < (Int)arg3; i++)
             SYSCALL_TRACK( pre_mem_write, tid, "readv(vector[...])",
                               (UInt)vec[i].iov_base,vec[i].iov_len );
          KERNEL_DO_SYSCALL(tid,res);
@@ -3369,14 +3369,14 @@ void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid )
 
       case __NR_writev: { /* syscall 146 */
          /* int writev(int fd, const struct iovec * vector, size_t count); */
-         UInt i;
+         Int i;
          struct iovec * vec;
          MAYBE_PRINTF("writev ( %d, %p, %d )\n",arg1,arg2,arg3);
          SYSCALL_TRACK( pre_mem_read, tid, "writev(vector)", 
                            arg2, arg3 * sizeof(struct iovec) );
          /* ToDo: don't do any of the following if the vector is invalid */
          vec = (struct iovec *)arg2;
-         for (i = 0; i < arg3; i++)
+         for (i = 0; i < (Int)arg3; i++)
             SYSCALL_TRACK( pre_mem_read, tid, "writev(vector[...])",
                               (UInt)vec[i].iov_base,vec[i].iov_len );
          KERNEL_DO_SYSCALL(tid,res);
index 8b562eca21dbaa4e34367154bb8bebebac8bccf4..f2ccf5b8cb85a34037340453400a54355defc8bd 100644 (file)
@@ -57,10 +57,12 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        tronical.stderr.exp tronical.vgtest \
        weirdioctl.stderr.exp weirdioctl.stdout.exp weirdioctl.vgtest \
        metadata.stderr.exp metadata.stdout.exp metadata.vgtest \
-       threadederrno.stderr.exp threadederrno.stdout.exp threadederrno.vgtest
+       threadederrno.stderr.exp threadederrno.stdout.exp \
+       threadederrno.vgtest \
+       writev.stderr.exp writev.vgtest
 
 check_PROGRAMS = \
-       badaddrvalue badfree badjump badloop brk buflen_check 
+       badaddrvalue badfree badjump badloop brk buflen_check \
        clientperm custom_alloc \
        doublefree error_counts errs1 exitprog fprw fwrite inits inline \
        malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
@@ -68,7 +70,7 @@ check_PROGRAMS = \
        overlap pushfpopf \
        realloc1 realloc2 realloc3 sigaltstack signal2 supp1 supp2 suppfree \
        trivialleak tronical weirdioctl \
-       mismatches new_override metadata threadederrno
+       mismatches new_override metadata threadederrno writev
 
 AM_CPPFLAGS = -I$(top_srcdir)/include
 AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g 
@@ -118,6 +120,7 @@ weirdioctl_SOURCES  = weirdioctl.c
 metadata_SOURCES       = metadata.c
 threadederrno_SOURCES  = threadederrno.c
 threadederrno_LDADD    = -lpthread
+writev_SOURCES         = writev.c
 
 # C++ ones
 mismatches_SOURCES     = mismatches.cpp
index 7f6793be80b95fdef35b4379966a450d951c69f1..f13167d251451b3a6b659048ce22f8f3502bfa14 100755 (executable)
@@ -17,6 +17,9 @@ sed "/For more details, rerun with: -v/d"                              |
 # Anonymise line numbers in vg_replace_malloc.c
 sed "s/vg_replace_malloc.c:[0-9]\+/vg_replace_malloc.c:.../"           |
 
+# Anonymise vg_intercept lines
+sed "s/vg_intercept.c:[0-9]\+/vg_intercept.c:.../"                     |
+
 # Reduce some libc incompatibility
 sed "s/ __getsockname / getsockname /"                                 |
 sed "s/ __sigaction / sigaction /"                                     |