Changeset 1676 for zzuf


Ignore:
Timestamp:
Jan 16, 2007, 2:54:34 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • readv() implementation, thanks to Rémi Denis-Courmont.
Location:
zzuf/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/AUTHORS

    r1656 r1676  
    11$Id$
    22
    3 zzuf was written by Sam Hocevar <sam@zoy.org>
     3main zzuf author:
     4 Sam Hocevar <sam@zoy.org>
     5
     6other contributors:
     7 Rémi Denis-Courmont <rdenis#simphalempin:com> (readv support)
     8
  • zzuf/trunk/doc/zzuf.1

    r1675 r1676  
    318318.TP
    319319Unix file descriptor handling:
    320 \fBopen\fR(), \fBlseek\fR(), \fBread\fR(), \fBaccept\fR(), \fBsocket\fR(),
    321 \fBclose\fR()
     320\fBopen\fR(), \fBlseek\fR(), \fBread\fR(), \freadv\fR(), \fBaccept\fR(),
     321\fBsocket\fR(), \fBclose\fR()
    322322.TP
    323323Standard IO streams:
  • zzuf/trunk/src/load-fd.c

    r1648 r1676  
    11/*
    22 *  zzuf - general purpose fuzzer
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006, 2007 Sam Hocevar <sam@zoy.org>
     4 *                2007 Rémi Denis-Courmont <rdenis#simphalempin:com>
    45 *                All Rights Reserved
    56 *
     
    3536#include <sys/types.h>
    3637#include <sys/socket.h>
     38#include <sys/uio.h>
    3739#include <unistd.h>
    3840#include <fcntl.h>
     
    6062static int     (*socket_orig)  (int domain, int type, int protocol);
    6163static ssize_t (*read_orig)    (int fd, void *buf, size_t count);
     64static ssize_t (*readv_orig)   (int fd, const struct iovec *iov, int count);
    6265static off_t   (*lseek_orig)   (int fd, off_t offset, int whence);
    6366#ifdef HAVE_LSEEK64
     
    163166}
    164167
     168static void offset_check(int fd)
     169{
     170    /* Sanity check, can be OK though (for instance with a character device) */
     171#ifdef HAVE_LSEEK64
     172    if(lseek64_orig(fd, 0, SEEK_CUR) != _zz_getpos(fd))
     173#else
     174    if(lseek_orig(fd, 0, SEEK_CUR) != _zz_getpos(fd))
     175#endif
     176        debug("warning: offset inconsistency");
     177}
     178
    165179ssize_t read(int fd, void *buf, size_t count)
    166180{
     
    189203        debug("read(%i, %p, %li) = %i", fd, buf, (long int)count, ret);
    190204
    191     /* Sanity check, can be OK though (for instance with a character device) */
    192 #ifdef HAVE_LSEEK64
    193     if(lseek64_orig(fd, 0, SEEK_CUR) != _zz_getpos(fd))
    194 #else
    195     if(lseek_orig(fd, 0, SEEK_CUR) != _zz_getpos(fd))
    196 #endif
    197         debug("warning: offset inconsistency");
    198 
     205    offset_check(fd);
     206    return ret;
     207}
     208
     209ssize_t readv(int fd, const struct iovec *iov, int count)
     210{
     211    ssize_t ret;
     212
     213    LOADSYM(readv);
     214    ret = readv_orig(fd, iov, count);
     215    if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled)
     216        return ret;
     217
     218    debug("readv(%i, %p, %i) = %li", fd, iov, count, (long int)ret);
     219
     220    while(ret > 0)
     221    {
     222        void *b = iov->iov_base;
     223        size_t len = iov->iov_len;
     224
     225        if(len > (size_t)ret)
     226            len = ret;
     227
     228        _zz_fuzz(fd, b, len);
     229        _zz_addpos(fd, len);
     230
     231        iov++;
     232        ret -= len;
     233    }
     234
     235    offset_check(fd);
    199236    return ret;
    200237}
Note: See TracChangeset for help on using the changeset viewer.