Commit: Fix impossible shift in CSKY disassembler

Message ID 87imo7nc7u.fsf@redhat.com
State New
Headers show
Series
  • Commit: Fix impossible shift in CSKY disassembler
Related show

Commit Message

Nick Clifton Oct. 29, 2019, 9:16 a.m.
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.

Patch

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--)