* Re: Question re: commit 2db20b97f1dc3e5dce3d6ed74a8a62f0dede8c80
[not found] <60cc240b-9d1b-486a-dfd4-1cb2bb3c0fae@redhat.com>
@ 2023-08-12 23:32 ` Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-08-12 23:32 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
On Sat, Aug 12, 2023 at 09:28:30AM -0700, Keith Seitz wrote:
> Hi,
>
> I see this was just committed to binutils-gdb:
>
> commit 2db20b97f1dc3e5dce3d6ed74a8a62f0dede8c80
> Author: Alan Modra <amodra@gmail.com>
> Date: Wed Aug 9 09:58:36 2023 +0930
>
> gdb: warn unused result for bfd IO functions
> This fixes the compilation warnings introduced by my bfdio.c patch.
>
> This commit contains this hunk:
>
> @@ -374,12 +395,13 @@ read_pe_exported_syms (minimal_symbol_reader &reader,
> {
> char sname[8];
> unsigned long secptr1 = secptr + 40 * i;
> - unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
> - unsigned long vsize = pe_get32 (dll, secptr1 + 16);
> - unsigned long fptr = pe_get32 (dll, secptr1 + 20);
> + unsigned long vaddr = pe_get32 (dll, secptr1 + 12, &fail);
> + unsigned long vsize = pe_get32 (dll, secptr1 + 16, &fail);
> + unsigned long fptr = pe_get32 (dll, secptr1 + 20, &fail);
> - bfd_seek (dll, (file_ptr) secptr1, SEEK_SET);
> - bfd_read (sname, (bfd_size_type) sizeof (sname), dll);
> + if (fail
> + || bfd_seek (dll, secptr1, SEEK_SET) != 0
> + || bfd_read (sname, sizeof (sname), dll) != sizeof (sname))
> if ((strcmp (sname, ".edata") == 0)
> || (vaddr <= export_opthdrrva && export_opthdrrva < vaddr + vsize))
>
> Maybe I'm just really out of touch, but can you explain that "if (fail\n|| bfd_seek..." block?
> It looks like it is missing a statement?
Indeed it is. I don't know how that happened, but it wasn't Andrew's
update to my patch. I'm committing the following as obvious.
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 0d76ebdbfce..56137ac4dd0 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -402,6 +402,7 @@ read_pe_exported_syms (minimal_symbol_reader &reader,
if (fail
|| bfd_seek (dll, secptr1, SEEK_SET) != 0
|| bfd_read (sname, sizeof (sname), dll) != sizeof (sname))
+ return maybe_print_debug_msg ();
if ((strcmp (sname, ".edata") == 0)
|| (vaddr <= export_opthdrrva && export_opthdrrva < vaddr + vsize))
> [I am hacking coff-pe-read.c to fix some CVEs that were filed against it.]
>
> Keith
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-12 23:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <60cc240b-9d1b-486a-dfd4-1cb2bb3c0fae@redhat.com>
2023-08-12 23:32 ` Question re: commit 2db20b97f1dc3e5dce3d6ed74a8a62f0dede8c80 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).