* Fix fread() issue with standard input reading.

This commit is contained in:
Sam Hocevar
2007-01-06 15:54:14 +00:00
committed by sam
parent e381e7bb86
commit 2029e77e18
2 changed files with 12 additions and 5 deletions
+5 -1
View File
@@ -179,8 +179,12 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
if(ret >= 0)
{
/* XXX: the number of bytes read is not ret * size, because
* a partial read may have advanced the stream pointer */
* a partial read may have advanced the stream pointer. However,
* when reading from a pipe ftell() will return 0, and ret * size
* is then better than nothing. */
long int newpos = ftell(stream);
if(newpos <= 0)
newpos = ret * size;
if(newpos != pos)
{
_zz_fuzz(fd, ptr, newpos - pos);