[binutils-gdb] metag uninitialized memory read

Alan Modra amodra@sourceware.org
Fri Mar 20 02:09:21 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=340f3ac8082771ecc473ab938fc3d7cbf607ddaa

commit 340f3ac8082771ecc473ab938fc3d7cbf607ddaa
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Mar 20 10:55:58 2020 +1030

    metag uninitialized memory read
    
            * metag-dis.c (print_insn_metag): Don't ignore status from
            read_memory_func.

Diff:
---
 opcodes/ChangeLog   |  5 +++++
 opcodes/metag-dis.c | 10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 2d6af2b5a0c..5f9229652fc 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-20  Alan Modra  <amodra@gmail.com>
+
+	* metag-dis.c (print_insn_metag): Don't ignore status from
+	read_memory_func.
+
 2020-03-20  Alan Modra  <amodra@gmail.com>
 
 	* nds32-dis.c (print_insn_nds32): Remove unnecessary casts.
diff --git a/opcodes/metag-dis.c b/opcodes/metag-dis.c
index f01dcbaef1d..b1cf6331b5d 100644
--- a/opcodes/metag-dis.c
+++ b/opcodes/metag-dis.c
@@ -3364,9 +3364,15 @@ print_insn_metag (bfd_vma pc, disassemble_info *outf)
   bfd_byte buf[4];
   unsigned int insn_word;
   size_t i;
-  outf->bytes_per_chunk = 4;
+  int status;
 
-  (*outf->read_memory_func) (pc & ~0x03, buf, 4, outf);
+  outf->bytes_per_chunk = 4;
+  status = (*outf->read_memory_func) (pc & ~0x03, buf, 4, outf);
+  if (status)
+    {
+      (*outf->memory_error_func) (status, pc, outf);
+      return -1;
+    }
   insn_word = bfd_getl32 (buf);
 
   for (i = 0; i < sizeof(metag_optab)/sizeof(metag_optab[0]); i++)


More information about the Binutils-cvs mailing list