diff --git a/src/fuzz.c b/src/fuzz.c index fe1d6a3..d981653 100644 --- a/src/fuzz.c +++ b/src/fuzz.c @@ -42,8 +42,10 @@ void _zz_fuzz(int fd, uint8_t *buf, uint64_t len) unsigned long int pos = _zz_getpos(fd); unsigned int i, j, todo; - fuzz = _zz_getfuzz(fd); + debug("fuzz(%i, %lli@%li)", fd, (unsigned long long int)len, + (unsigned long int)pos); + fuzz = _zz_getfuzz(fd); aligned_buf = buf - pos; for(i = pos / CHUNKBYTES; diff --git a/src/load-stream.c b/src/load-stream.c index 92aac09..6641c14 100644 --- a/src/load-stream.c +++ b/src/load-stream.c @@ -167,8 +167,11 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) /* XXX: the number of bytes read is not ret * size, because * a partial read may have advanced the stream pointer */ long int newpos = ftell(stream); - _zz_fuzz(fd, ptr, newpos - pos); - _zz_setpos(fd, newpos); + if(newpos != pos) + { + _zz_fuzz(fd, ptr, newpos - pos); + _zz_setpos(fd, newpos); + } } return ret; }