Account for trailing bytes read from bfd_bread
Alan Modra
amodra@gmail.com
Tue Jul 15 04:17:00 GMT 2014
Noticed when debugging the >2G obstack corruption of gdb data. When
we have a truncated read, we ought to return the amount read. Not
that it matters very much on an error return..
* cache.c (cache_bread_1): Don't return -1 when fread returns
a positive value.
diff --git a/bfd/cache.c b/bfd/cache.c
index 27fe70a..ffda004 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -310,7 +310,7 @@ cache_bread_1 (struct bfd *abfd, void *buf, file_ptr nbytes)
if (nread == (file_ptr)-1)
{
bfd_set_error (bfd_error_system_call);
- return -1;
+ return nread;
}
#else
nread = fread (buf, 1, nbytes, f);
@@ -320,7 +320,7 @@ cache_bread_1 (struct bfd *abfd, void *buf, file_ptr nbytes)
if (nread < nbytes && ferror (f))
{
bfd_set_error (bfd_error_system_call);
- return -1;
+ return nread;
}
#endif
if (nread < nbytes)
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list