Fix unintialized memory in aarch64 opcodes.
authorTamar Christina <tamar.christina@arm.com>
Tue, 1 May 2018 16:11:11 +0000 (17:11 +0100)
committerTamar Christina <tamar.christina@arm.com>
Tue, 1 May 2018 16:12:58 +0000 (17:12 +0100)
This patch fixes an issue where the memory for the opcode structure is not zero'd before
the first exit branch. So there is one failure mode for which uninitialized memory
is returned.

This causes weird failures when the return code is not checked before inst is used.

opcodes/

* aarch64-dis.c (aarch64_opcode_decode): Moved memory clear code.

opcodes/ChangeLog
opcodes/aarch64-dis.c

index e0834bf595e72f3af6896d3280f23d6ea43635d5..3c2cf1638425d785a077f6d716c74714e80094b8 100644 (file)
@@ -1,3 +1,7 @@
+2018-05-01  Tamar Christina  <tamar.christina@arm.com>
+
+       * aarch64-dis.c (aarch64_opcode_decode): Moved memory clear code.
+
 2018-04-30  Francois H. Theron <francois.theron@netronome.com>
 
        Makefile.am: Added nfp-dis.c.
index c63f595f682bf11b602e8cb8026b9600e8f665f6..e7bece9c1ac4b444dfcd7a35a18d1809d94c734d 100644 (file)
@@ -2733,6 +2733,9 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
 
   assert (opcode && inst);
 
+  /* Clear inst.  */
+  memset (inst, '\0', sizeof (aarch64_inst));
+
   /* Check the base opcode.  */
   if ((code & opcode->mask) != (opcode->opcode & opcode->mask))
     {
@@ -2740,9 +2743,6 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
       goto decode_fail;
     }
 
-  /* Clear inst.  */
-  memset (inst, '\0', sizeof (aarch64_inst));
-
   inst->opcode = opcode;
   inst->value = code;
 
This page took 0.025744 seconds and 4 git commands to generate.