From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCFao-0005Pz-D0 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 19:14:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCFam-0007wN-6J for qemu-devel@nongnu.org; Mon, 06 Jul 2015 19:14:30 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44135 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCFal-0007r7-Tj for qemu-devel@nongnu.org; Mon, 06 Jul 2015 19:14:28 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 7 Jul 2015 01:14:04 +0200 Message-Id: <1436224445-19449-22-git-send-email-afaerber@suse.de> In-Reply-To: <1436224445-19449-1-git-send-email-afaerber@suse.de> References: <1436224445-19449-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 21/22] 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 Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Peter Crosthwaite From: Peter Crosthwaite 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. Reviewed-by: Edgar E. Iglesias Signed-off-by: Peter Crosthwaite Signed-off-by: Andreas F=C3=A4rber --- 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. */ =20 - nbytes =3D info->buffer_length; - if (nbytes > MAX_BYTES_PER_CRIS_INSN) - nbytes =3D MAX_BYTES_PER_CRIS_INSN; + nbytes =3D info->buffer_length ? info->buffer_length + : MAX_BYTES_PER_CRIS_INSN; + nbytes =3D MIN(nbytes, MAX_BYTES_PER_CRIS_INSN); status =3D (*info->read_memory_func) (memaddr, buffer, nbytes, info); = =20 =20 /* If we did not get all we asked for, then clear the rest. --=20 2.1.4