2010-06-09 Tristan Gingold <gingold@adacore.com>

* bfdio.c (bfd_bread): Fix the code to prevent reading past the
	end of archive members.
This commit is contained in:
Tristan Gingold 2010-06-09 13:28:31 +00:00
parent 5ddb52faff
commit f0b3dbfc47
2 changed files with 11 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2010-06-09 Tristan Gingold <gingold@adacore.com>
* bfdio.c (bfd_bread): Fix the code to prevent reading past the
end of archive members.
2010-06-08 Tristan Gingold <gingold@adacore.com> 2010-06-08 Tristan Gingold <gingold@adacore.com>
* som.c (som_bfd_free_cached_info): Do not free relocations as * som.c (som_bfd_free_cached_info): Do not free relocations as

View file

@ -180,8 +180,12 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
if (abfd->arelt_data != NULL) if (abfd->arelt_data != NULL)
{ {
size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size; size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size;
if (size > maxbytes) if (abfd->where + size > maxbytes)
size = maxbytes; {
if (abfd->where >= maxbytes)
return 0;
size = maxbytes - abfd->where;
}
} }
if (abfd->iovec) if (abfd->iovec)