aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2006-12-14 02:59:25 +0000
committerAlan Modra <amodra@gmail.com>2006-12-14 02:59:25 +0000
commit1fb41da414b7826e82d65cb644d00508d5b92458 (patch)
treecc4b92098b82b5d02b5d9a362919d075d6c3c906
parent15f6818fba9b2ba0283f6a0158e33cae7724b2e4 (diff)
downloadgdb-1fb41da414b7826e82d65cb644d00508d5b92458.zip
gdb-1fb41da414b7826e82d65cb644d00508d5b92458.tar.gz
gdb-1fb41da414b7826e82d65cb644d00508d5b92458.tar.bz2
PR 3704
* bfdio.c (bfd_bread): Don't read past end of archive elements.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/bfdio.c11
2 files changed, 15 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 4a55286..f15fdd3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-14 Alan Modra <amodra@bigpond.net.au>
+
+ PR 3704
+ * bfdio.c (bfd_bread): Don't read past end of archive elements.
+
2006-12-12 Daniel Jacobowitz <dan@codesourcery.com>
* doc/Makefile.am (bfd_TEXINFOS): Set.
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 0aa82a9..0c720f6 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -1,7 +1,7 @@
/* Low-level I/O routines for BFDs.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -116,6 +116,15 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
{
size_t nread;
+ /* If this is an archive element, don't read past the end of
+ this element. */
+ if (abfd->arelt_data != NULL)
+ {
+ size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size;
+ if (size > maxbytes)
+ size = maxbytes;
+ }
+
if ((abfd->flags & BFD_IN_MEMORY) != 0)
{
struct bfd_in_memory *bim;