aboutsummaryrefslogtreecommitdiff
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
commitf0b3dbfc47e96c4c0dfabb010e34923dedfaae87 (patch)
tree8e04717f1016357e117b887f15d55a1f1e009deb /bfd/bfdio.c
parent5ddb52faff9c516e96892f44e9e5b47d8b19e0bb (diff)
downloadgdb-f0b3dbfc47e96c4c0dfabb010e34923dedfaae87.zip
gdb-f0b3dbfc47e96c4c0dfabb010e34923dedfaae87.tar.gz
gdb-f0b3dbfc47e96c4c0dfabb010e34923dedfaae87.tar.bz2
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 4c13a76..ce92781 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)