This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Account for trailing bytes read from bfd_bread
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 15 Jul 2014 13:47:26 +0930
- Subject: Account for trailing bytes read from bfd_bread
- Authentication-results: sourceware.org; auth=none
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