From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: alpha-coff: large memory allocation
Date: Mon, 02 Mar 2020 01:02:00 -0000 [thread overview]
Message-ID: <20200302010152.GD5384@bubble.grove.modra.org> (raw)
* 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
reply other threads:[~2020-03-02 1:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200302010152.GD5384@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).