* [binutils-gdb] Re: More ecoff sanity checks
@ 2023-06-03 8:06 Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2023-06-03 8:06 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c6e6e3ab2b70458d34c4a7a2e7e1637d38d49e8f
commit c6e6e3ab2b70458d34c4a7a2e7e1637d38d49e8f
Author: Alan Modra <amodra@gmail.com>
Date: Sat Jun 3 12:39:06 2023 +0930
Re: More ecoff sanity checks
Yet another fuzzer fix.
* ecoff.c (ecoff_slurp_symbolic_header <FIX>): Zero counts when
associated pointer is zero.
(_bfd_ecoff_slurp_symbolic_info): Remove now unnecessary check.
Diff:
---
bfd/ecoff.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index f2930569f21..c4c2e530be0 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -468,6 +468,23 @@ ecoff_slurp_symbolic_header (bfd *abfd)
goto error_return;
}
+#define FIX(start, count) \
+ if (internal_symhdr->start == 0) \
+ internal_symhdr->count = 0;
+
+ FIX (cbLineOffset, cbLine);
+ FIX (cbDnOffset, idnMax);
+ FIX (cbPdOffset, ipdMax);
+ FIX (cbSymOffset, isymMax);
+ FIX (cbOptOffset, ioptMax);
+ FIX (cbAuxOffset, iauxMax);
+ FIX (cbSsOffset, issMax);
+ FIX (cbSsExtOffset, issExtMax);
+ FIX (cbFdOffset, ifdMax);
+ FIX (cbRfdOffset, crfd);
+ FIX (cbExtOffset, iextMax);
+#undef FIX
+
/* Now we can get the correct number of symbols. */
abfd->symcount = internal_symhdr->isymMax + internal_symhdr->iextMax;
@@ -580,7 +597,7 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
/* Get pointers for the numeric offsets in the HDRR structure. */
#define FIX(start, count, ptr, type) \
- if (internal_symhdr->start == 0 || internal_symhdr->count == 0) \
+ if (internal_symhdr->count == 0) \
debug->ptr = NULL; \
else \
debug->ptr = (type) ((char *) raw \
^ permalink raw reply [flat|nested] 2+ messages in thread
* [binutils-gdb] Re: More ecoff sanity checks
@ 2023-06-02 0:12 Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2023-06-02 0:12 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e0ce6dde97881435d33652572789b94c846cacde
commit e0ce6dde97881435d33652572789b94c846cacde
Author: Alan Modra <amodra@gmail.com>
Date: Fri Jun 2 08:21:36 2023 +0930
Re: More ecoff sanity checks
Another fix for fuzzed object files, exhibiting as a segfault in
nm.c filter_symbols when accessing a symbol name.
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check
fdr_ptr->issBase, and tighten sym.iss check.
Diff:
---
bfd/ecoff.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 676b8d84017..f2930569f21 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -942,7 +942,9 @@ _bfd_ecoff_slurp_symbol_table (bfd *abfd)
if (fdr_ptr->isymBase < 0
|| fdr_ptr->isymBase > symhdr->isymMax
|| fdr_ptr->csym <= 0
- || fdr_ptr->csym > symhdr->isymMax - fdr_ptr->isymBase)
+ || fdr_ptr->csym > symhdr->isymMax - fdr_ptr->isymBase
+ || fdr_ptr->issBase < 0
+ || fdr_ptr->issBase > symhdr->issMax)
continue;
lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym
+ fdr_ptr->isymBase * external_sym_size);
@@ -955,7 +957,7 @@ _bfd_ecoff_slurp_symbol_table (bfd *abfd)
(*swap_sym_in) (abfd, (void *) lraw_src, &internal_sym);
- if (internal_sym.iss >= symhdr->issMax
+ if (internal_sym.iss >= symhdr->issMax - fdr_ptr->issBase
|| internal_sym.iss < 0)
{
bfd_set_error (bfd_error_bad_value);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-03 8:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-03 8:06 [binutils-gdb] Re: More ecoff sanity checks Alan Modra
-- strict thread matches above, loose matches on Subject: below --
2023-06-02 0:12 Alan Modra
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).