Ignore:
Timestamp:
Jul 24, 2008, 1:40:06 AM (12 years ago)
Author:
Sam Hocevar
Message:
  • zzuf.c: make the -B flag (max bytes) also work when fuzzing the standard input.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.