From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YrB65-0004f8-TX for qemu-devel@nongnu.org; Sat, 09 May 2015 16:11:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YrB62-0007kq-Q6 for qemu-devel@nongnu.org; Sat, 09 May 2015 16:11:41 -0400 Received: from mail-pd0-x234.google.com ([2607:f8b0:400e:c02::234]:34830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YrB62-0007ke-Jn for qemu-devel@nongnu.org; Sat, 09 May 2015 16:11:38 -0400 Received: by pdbqd1 with SMTP id qd1so114641993pdb.2 for ; Sat, 09 May 2015 13:11:38 -0700 (PDT) From: Peter Crosthwaite Date: Sat, 9 May 2015 13:11:16 -0700 Message-Id: <65ea9e7de239d6f3f8b98e347948e99f19e923fd.1431200693.git.crosthwaite.peter@gmail.com> In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH v2 6/7] disas: cris: Fix 0 buffer length case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, edgari@xilinx.com, rth@twiddle.net, claudio.fontana@huawei.com, edgar.iglesias@gmail.com Cris has the complication of variable length instructions and has a check in place to clamp memory reads in case the disas request doesn't have enough bytes for the instruction being disas'd. This breaks down in the case where disassembling for the monitor where the buffer length is defaulted to 0. The buffer length should never be zero for a regular target_disas, so we can safely assume the 0 case is for the monitor in which case consider the buffer length to be the max for cris instructions. Signed-off-by: Peter Crosthwaite --- disas/cris.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/disas/cris.c b/disas/cris.c index e6cff7a..1b76a09 100644 --- a/disas/cris.c +++ b/disas/cris.c @@ -2575,9 +2575,9 @@ print_insn_cris_generic (bfd_vma memaddr, If we can't get any data, or we do not get enough data, we print the error message. */ - nbytes = info->buffer_length; - if (nbytes > MAX_BYTES_PER_CRIS_INSN) - nbytes = MAX_BYTES_PER_CRIS_INSN; + nbytes = info->buffer_length ? info->buffer_length + : MAX_BYTES_PER_CRIS_INSN; + nbytes = MIN(nbytes, MAX_BYTES_PER_CRIS_INSN); status = (*info->read_memory_func) (memaddr, buffer, nbytes, info); /* If we did not get all we asked for, then clear the rest. -- 1.9.1