This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Commit: Fix impossible shift in CSKY disassembler
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Tue, 29 Oct 2019 09:16:21 +0000
- Subject: Commit: Fix impossible shift in CSKY disassembler
Hi Guys,
I am applying the patch below to fix a potential out of range shift
and assignment in the CSky disassembler.
Cheers
Nick
opcodes/ChangeLog
2019-10-28 Nick Clifton <nickc@redhat.com>
* csky-dis.c (csky_chars_to_number): Check for a negative
count. Use an unsigned integer to construct the return value.
diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index efd1f75052..ffdb596495 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -134,10 +134,10 @@ csky_get_mask (struct csky_opcode_info const *pinfo)
static unsigned int
csky_chars_to_number (unsigned char * buf, int n)
{
- if (n == 0)
+ if (n <= 0)
abort ();
int i;
- int val = 0;
+ unsigned int val = 0;
if (dis_info.info->endian == BFD_ENDIAN_BIG)
while (n--)