alpha-coff: large memory allocation
Alan Modra
amodra@gmail.com
Mon Mar 2 01:02:00 GMT 2020
More information about the Binutils mailing list
Mon Mar 2 01:02:00 GMT 2020
- Previous message (by thread): alpha-vms: prevent endless recursion
- Next message (by thread): elf_backend_section_flags and _bfd_elf_init_private_section_data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Provide an upper
limit to decompressed element size.
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 4b39bcc999..9a3ac089a6 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -2050,6 +2050,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
bfd_size_type size;
bfd_byte *buf, *p;
struct bfd_in_memory *bim;
+ ufile_ptr filesize;
buf = NULL;
nbfd = _bfd_get_elt_at_filepos (archive, filepos);
@@ -2083,6 +2084,14 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
goto error_return;
size = H_GET_64 (nbfd, ab);
+ /* The decompression algorithm will at most expand by eight times. */
+ filesize = bfd_get_file_size (archive);
+ if (filesize != 0 && size / 8 > filesize)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ goto error_return;
+ }
+
if (size != 0)
{
bfd_size_type left;
--
Alan Modra
Australia Development Lab, IBM
- Previous message (by thread): alpha-vms: prevent endless recursion
- Next message (by thread): elf_backend_section_flags and _bfd_elf_init_private_section_data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list