]> git.proxmox.com Git - mirror_qemu.git/commitdiff
disas/cris: Avoid unintended sign extension
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 3 Mar 2017 15:50:32 +0000 (15:50 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 7 Mar 2017 14:33:51 +0000 (14:33 +0000)
In the cris disassembler we were using 'unsigned long' to calculate
addresses which are supposed to be 32 bits.  This meant that we might
accidentally sign extend or calculate a value that was outside the 32
bit range of the guest CPU.  Use 'uint32_t' instead so we give the
right answers on 64-bit hosts.

(Spotted by Coverity, CID 10054021005403.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1488556233-31246-6-git-send-email-peter.maydell@linaro.org

disas/cris.c

index 8a1daf936ca5cd9ead76e61229345a8d919d4483..30217f17f9842b30c6c1120ffa9353689a089678 100644 (file)
@@ -2009,7 +2009,7 @@ print_with_operands (const struct cris_opcode *opcodep,
       case 'n':
        {
          /* Like N but pc-relative to the start of the insn.  */
-         unsigned long number
+         uint32_t number
            = (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
               + buffer[5] * 0x1000000 + addr);
 
@@ -2201,7 +2201,7 @@ print_with_operands (const struct cris_opcode *opcodep,
                      {
                        /* It's [pc+].  This cannot possibly be anything
                           but an address.  */
-                       unsigned long number
+                       uint32_t number
                          = prefix_buffer[2] + prefix_buffer[3] * 256
                          + prefix_buffer[4] * 65536
                          + prefix_buffer[5] * 0x1000000;