* Do not fuzz anything if 0 bytes were read.

* Added a debug message for fuzzing.
This commit is contained in:
Sam Hocevar
2007-01-03 22:25:45 +00:00
committed by sam
parent ead4987c3b
commit 5d89130fb9
2 changed files with 8 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;
}