* Account for trailing bytes read from bfd_bread
@ 2014-07-15 4:17 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2014-07-15 4:17 UTC (permalink / raw)
To: binutils
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-07-15 4:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15 4:17 Account for trailing bytes read from bfd_bread Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).