Changeset 2583

Show
Ignore:
Timestamp:
07/24/08 01:40:06 (3 months ago)
Author:
sam
Message:
  • zzuf.c: make the -B flag (max bytes) also work when fuzzing the standard input.
Location:
zzuf/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/doc/zzuf.1

    r2521 r2583  
    5858.TP 
    5959\fB\-B\fR, \fB\-\-max\-bytes\fR=\fIn\fR 
    60 Automatically terminate child processes that output more than \fIn\fR bytes 
    61 on the standard output and standard error channels. This is useful to detect 
    62 infinite loops. See also the \fB\-t\fR and \fB\-T\fR flags. 
     60Automatically stop after \fIn\fR bytes have been output. 
     61 
     62This either terminates child processes that output more than \fIn\fR bytes 
     63on the standard output and standard error channels, or stop reading from 
     64standard input if no program is being fuzzed. 
     65 
     66This is useful to detect infinite loops. See also the \fB\-t\fR and \fB\-T\fR 
     67flags. 
    6368.TP 
    6469\fB\-c\fR, \fB\-\-cmdline\fR 
  • zzuf/trunk/src/zzuf.c

    r2555 r2583  
    471471    uint8_t md5sum[16]; 
    472472    struct md5 *ctx = NULL; 
     473    int total = 0; 
    473474 
    474475    if(opts->md5) 
     
    494495    { 
    495496        uint8_t buf[BUFSIZ]; 
    496         int ret, off = 0, nw = 0; 
    497  
    498         ret = read(0, buf, BUFSIZ); 
     497        int ret, toread = BUFSIZ, off = 0, nw = 0; 
     498 
     499        if(opts->maxbytes >= 0) 
     500        { 
     501            if(total >= opts->maxbytes) 
     502                break; 
     503            if(total + BUFSIZ >= opts->maxbytes) 
     504                toread = opts->maxbytes - total; 
     505        } 
     506 
     507        ret = read(0, buf, toread); 
    499508        if(ret <= 0) 
    500509            break; 
     510 
     511        total += ret; 
    501512 
    502513        _zz_fuzz(0, buf, ret);