public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Harmstone <mark@harmstone.com>
To: binutils@sourceware.org, amodra@gmail.com
Cc: Mark Harmstone <mark@harmstone.com>
Subject: [PATCH] Avoid divide by zero when reading invalid PDB archive
Date: Fri, 16 Sep 2022 01:40:34 +0100	[thread overview]
Message-ID: <20220916004034.10189-1-mark@harmstone.com> (raw)

As discovered by Alan Modra - see
https://sourceware.org/pipermail/binutils/2022-September/122878.html.

---
 bfd/pdb.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bfd/pdb.c b/bfd/pdb.c
index 9a431c23b1f..0ce3bc46ac6 100644
--- a/bfd/pdb.c
+++ b/bfd/pdb.c
@@ -80,6 +80,12 @@ pdb_get_elt_at_index (bfd *abfd, symindex sym_index)
 
   block_size = bfd_getl32 (int_buf);
 
+  if (block_size == 0)
+    {
+      bfd_set_error (bfd_error_malformed_archive);
+      return NULL;
+    }
+
   /* Get block_map_addr.  */
 
   if (bfd_seek (abfd, 4 * sizeof (uint32_t), SEEK_CUR))
-- 
2.35.1


             reply	other threads:[~2022-09-16  0:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16  0:40 Mark Harmstone [this message]
2022-09-16  3:31 ` Alan Modra

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=20220916004034.10189-1-mark@harmstone.com \
    --to=mark@harmstone.com \
    --cc=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).