From 87f14779da25380b2e1ee67edcf984f0f8c922c4 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 9 Jul 2014 20:04:40 +0930 Subject: [PATCH] Account for trailing bytes read from bfd_bread * cache.c (cache_bread_1): Don't return -1 when fread returns a positive value. --- bfd/ChangeLog | 5 +++++ bfd/cache.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8c922aa7a87..96f85f7013c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2014-07-15 Alan Modra + + * cache.c (cache_bread_1): Don't return -1 when fread returns + a positive value. + 2014-07-15 Alan Modra * elflink.c (elf_merge_st_other): Update comments. Simplify diff --git a/bfd/cache.c b/bfd/cache.c index 27fe70a84c6..ffda00452de 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) -- 2.30.2