This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix possible array overrun in tc-i386.c
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Fri, 20 Jan 2017 10:32:06 +0000
- Subject: Fix possible array overrun in tc-i386.c
- Authentication-results: sourceware.org; auth=none
Hi Guys,
I am applying the patch below to fix a possible array overrun in
tc-i386.c detected by the Coverty scanner.
Cheers
Nick
gas/ChangeLog
2017-01-20 Nick Clifton <nickc@redhat.com>
* config/tc-i386.c (parse_operands): Check for operand overflow
before setting the unspecified bit.
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 80812cf..1fc6bc7 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -4136,13 +4136,13 @@ parse_operands (char *l, const char *mnemonic)
{ /* Yes, we've read in another operand. */
unsigned int operand_ok;
this_operand = i.operands++;
- i.types[this_operand].bitfield.unspecified = 1;
if (i.operands > MAX_OPERANDS)
{
as_bad (_("spurious operands; (%d operands/instruction max)"),
MAX_OPERANDS);
return NULL;
}
+ i.types[this_operand].bitfield.unspecified = 1;
/* Now parse operand adding info to 'i' as we go along. */
END_STRING_AND_SAVE (l);