Changeset 1691 for zzuf


Ignore:
Timestamp:
Jan 17, 2007, 6:14:22 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • recvmsg() support by Rémi Denis-Courmont.
  • Minor code reorganisation.
Location:
zzuf/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/AUTHORS

    r1686 r1691  
    55
    66other contributors:
    7  Rémi Denis-Courmont <rdenis#simphalempin:com> (readv support)
    8  Clément Stenac <zorglub#diwi:org> (pread support)
    9  Dominik Kuhlen <dominik.kuhlen#gmit-gmbh:de> (recvfrom support)
     7 Rémi Denis-Courmont <rdenis#simphalempin:com> (readv, recvmsg)
     8 Clément Stenac <zorglub#diwi:org> (pread)
     9 Dominik Kuhlen <dominik.kuhlen#gmit-gmbh:de> (recvfrom)
    1010
  • zzuf/trunk/doc/zzuf.1

    r1686 r1691  
    322322Unix file descriptor handling:
    323323\fBopen\fR(), \fBlseek\fR(), \fBread\fR(), \fBreadv\fR(), \fBpread\fR(),
    324 \fBaccept\fR(), \fBsocket\fR(), \fBrecvfrom\fR(), \fBclose\fR()
     324\fBaccept\fR(), \fBsocket\fR(), \fBrecv\fR(), \fBrecvfrom\fR(), \fBrecvmsg\fR(),
     325\fBclose\fR()
    325326.TP
    326327Standard IO streams:
  • zzuf/trunk/src/lib-fd.c

    r1690 r1691  
    5555#endif
    5656
     57/* Local prototypes */
     58static void fuzz_iovec   (int fd, const struct iovec *iov, ssize_t ret);
     59static void offset_check (int fd);
     60
    5761/* Library functions that we divert */
    5862static int     (*open_orig)    (const char *file, int oflag, ...);
     
    6670static int     (*recvfrom_orig)(int s, void *buf, size_t len, int flags,
    6771                                struct sockaddr *from, SOCKLEN_T *fromlen);
     72static int     (*recvmsg_orig) (int s,  struct msghdr *hdr, int flags);
    6873static ssize_t (*read_orig)    (int fd, void *buf, size_t count);
    6974static ssize_t (*readv_orig)   (int fd, const struct iovec *iov, int count);
     
    217222}
    218223
    219 static void offset_check(int fd)
    220 {
    221     /* Sanity check, can be OK though (for instance with a character device) */
    222 #ifdef HAVE_LSEEK64
    223     off64_t ret;
    224     LOADSYM(lseek64);
    225     ret = lseek64_orig(fd, 0, SEEK_CUR);
    226 #else
    227     off_t ret;
    228     LOADSYM(lseek);
    229     ret = lseek_orig(fd, 0, SEEK_CUR);
    230 #endif
    231     if(ret != -1 && ret != _zz_getpos(fd))
    232         debug("warning: offset inconsistency");
     224int recvmsg(int s, struct msghdr *hdr, int flags)
     225{
     226    ssize_t ret;
     227
     228    LOADSYM(recvmsg);
     229    ret = recvmsg_orig(s, hdr, flags);
     230    if(!_zz_ready || !_zz_iswatched(s) || _zz_disabled)
     231        return ret;
     232
     233    fuzz_iovec(s, hdr->msg_iov, ret);
     234    debug("%s(%i, %p, %x) = %li", __func__, s, hdr, flags, (long int)ret);
     235
     236    return ret;
    233237}
    234238
     
    272276        return ret;
    273277
     278    fuzz_iovec(fd, iov, ret);
    274279    debug("%s(%i, %p, %i) = %li", __func__, fd, iov, count, (long int)ret);
    275 
    276     while(ret > 0)
    277     {
    278         void *b = iov->iov_base;
    279         size_t len = iov->iov_len;
    280 
    281         if(len > (size_t)ret)
    282             len = ret;
    283 
    284         _zz_fuzz(fd, b, len);
    285         _zz_addpos(fd, len);
    286 
    287         iov++;
    288         ret -= len;
    289     }
    290280
    291281    offset_check(fd);
     
    374364}
    375365
     366/* XXX: the following functions are local */
     367
     368static void fuzz_iovec (int fd, const struct iovec *iov, ssize_t ret)
     369{
     370    /* NOTE: We assume that iov countains at least <ret> bytes. */
     371    while(ret > 0)
     372    {
     373        void *b = iov->iov_base;
     374        size_t len = iov->iov_len;
     375
     376        if(len > (size_t)ret)
     377            len = ret;
     378
     379        _zz_fuzz(fd, b, len);
     380        _zz_addpos(fd, len);
     381
     382        iov++;
     383        ret -= len;
     384    }
     385}
     386
     387static void offset_check(int fd)
     388{
     389    /* Sanity check, can be OK though (for instance with a character device) */
     390#ifdef HAVE_LSEEK64
     391    off64_t ret;
     392    LOADSYM(lseek64);
     393    ret = lseek64_orig(fd, 0, SEEK_CUR);
     394#else
     395    off_t ret;
     396    LOADSYM(lseek);
     397    ret = lseek_orig(fd, 0, SEEK_CUR);
     398#endif
     399    if(ret != -1 && ret != _zz_getpos(fd))
     400        debug("warning: offset inconsistency");
     401}
     402
Note: See TracChangeset for help on using the changeset viewer.