From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: More _bfd_ecoff_locate_line sanity checks
Date: Mon, 6 Mar 2023 14:02:16 +1030 [thread overview]
Message-ID: <ZAVewBOf2ip1On9w@squeak.grove.modra.org> (raw)
* ecofflink.c (mk_fdrtab): Discard fdr with negative cpd.
(lookup_line): Sanity check fdr cbLineOffset and cbLine.
Sanity check pdr cbLineOffset.
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
index 00f1e3da404..bba25929f2c 100644
--- a/bfd/ecofflink.c
+++ b/bfd/ecofflink.c
@@ -1742,6 +1742,7 @@ mk_fdrtab (bfd *abfd,
/* Sanity check fdr procedure descriptor pointer. */
long ipdMax = debug_info->symbolic_header.ipdMax;
if (fdr_ptr->ipdFirst >= ipdMax
+ || fdr_ptr->cpd < 0
|| fdr_ptr->cpd > ipdMax - fdr_ptr->ipdFirst)
fdr_ptr->cpd = 0;
/* Skip FDRs that have no PDRs. */
@@ -2146,12 +2147,20 @@ lookup_line (bfd *abfd,
are stored in a very funky format, which I won't try to
describe. The search is bounded by the end of the FDRs line
number entries. */
- line_end = debug_info->line + fdr_ptr->cbLineOffset + fdr_ptr->cbLine;
+ line_ptr = line_end = debug_info->line;
+ if (fdr_ptr->cbLineOffset < debug_info->symbolic_header.cbLine
+ && fdr_ptr->cbLine <= (debug_info->symbolic_header.cbLine
+ - fdr_ptr->cbLineOffset)
+ && pdr.cbLineOffset <= (debug_info->symbolic_header.cbLine
+ - fdr_ptr->cbLineOffset))
+ {
+ line_end += fdr_ptr->cbLineOffset + fdr_ptr->cbLine;
+ line_ptr += fdr_ptr->cbLineOffset + pdr.cbLineOffset;
+ }
/* Make offset relative to procedure entry. */
offset -= pdr.adr - 0x10 * pdr.prof;
lineno = pdr.lnLow;
- line_ptr = debug_info->line + fdr_ptr->cbLineOffset + pdr.cbLineOffset;
while (line_ptr < line_end)
{
int delta;
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2023-03-06 3:32 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=ZAVewBOf2ip1On9w@squeak.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).