summaryrefslogtreecommitdiff
path: root/bfd/bfdio.c
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2010-06-09 13:28:31 +0000
committerTristan Gingold <gingold@adacore.com>2010-06-09 13:28:31 +0000
commitc0274f2f8d471c66c519f23758f358e6643de997 (patch)
tree73cab19d554389dfde76e313ca1f1ea36a269c22 /bfd/bfdio.c
parent8ae038ce5f8b2d58eb28b5622d9b5c00e32f9256 (diff)
downloadbinutils-redhat-c0274f2f8d471c66c519f23758f358e6643de997.tar.gz
2010-06-09 Tristan Gingold <gingold@adacore.com>
* bfdio.c (bfd_bread): Fix the code to prevent reading past the end of archive members.
Diffstat (limited to 'bfd/bfdio.c')
-rw-r--r--bfd/bfdio.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 4c13a76738..ce92781d50 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -180,8 +180,12 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
if (abfd->arelt_data != NULL)
{
size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size;
- if (size > maxbytes)
- size = maxbytes;
+ if (abfd->where + size > maxbytes)
+ {
+ if (abfd->where >= maxbytes)
+ return 0;
+ size = maxbytes - abfd->where;
+ }
}
if (abfd->iovec)