Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Commit: AArch64 sim: Fix off by one error checking for invalid vector array element
@ 2016-03-18 14:44 Nick Clifton
  2016-03-18 14:54 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2016-03-18 14:44 UTC (permalink / raw)
  To: gdb-patches

Hi Guys,

  I am checking in the patch below to fix an off-by-one error pointed
  out by Mike Frysinger in my previous delta to the AArch64 simulator's
  vector register get and set functions.

Cheers
  Nick

sim/aarch64/ChangeLog
2016-03-18  Nick Clifton  <nickc@redhat.com>

	* cpustate.c (GET_VEC_ELEMENT): Fix off by one error checking
	for an invalid element index.
	(SET_VEC_ELEMENT): Likewise.

diff --git a/sim/aarch64/cpustate.c b/sim/aarch64/cpustate.c
index 86b1b15..19f485e 100644
--- a/sim/aarch64/cpustate.c
+++ b/sim/aarch64/cpustate.c
@@ -345,7 +345,7 @@ aarch64_set_FP_long_double (sim_cpu *cpu, VReg reg, FRegister a)
 #define GET_VEC_ELEMENT(REG, ELEMENT, FIELD)	   \
   do						   \
     {						   \
-      if (element > ARRAY_SIZE (cpu->fr[0].FIELD)) \
+      if (element >= ARRAY_SIZE (cpu->fr[0].FIELD)) \
 	{								\
 	  TRACE_REGISTER (cpu, \
 			  "Internal SIM error: invalid element number: %d ",\
@@ -421,7 +421,7 @@ aarch64_get_vec_double (sim_cpu *cpu, VReg reg, unsigned element)
 #define SET_VEC_ELEMENT(REG, ELEMENT, VAL, FIELD, PRINTER)	\
   do						   		\
     {								\
-      if (ELEMENT > ARRAY_SIZE (cpu->fr[0].FIELD))			\
+      if (ELEMENT >= ARRAY_SIZE (cpu->fr[0].FIELD))			\
 	{								\
 	  TRACE_REGISTER (cpu, \
 			  "Internal SIM error: invalid element number: %d ",\


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Commit: AArch64 sim: Fix off by one error checking for invalid vector array element
  2016-03-18 14:44 Commit: AArch64 sim: Fix off by one error checking for invalid vector array element Nick Clifton
@ 2016-03-18 14:54 ` Andreas Schwab
  2016-03-18 17:10   ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2016-03-18 14:54 UTC (permalink / raw)
  To: Nick Clifton; +Cc: gdb-patches

Nick Clifton <nickc@redhat.com> writes:

> diff --git a/sim/aarch64/cpustate.c b/sim/aarch64/cpustate.c
> index 86b1b15..19f485e 100644
> --- a/sim/aarch64/cpustate.c
> +++ b/sim/aarch64/cpustate.c
> @@ -345,7 +345,7 @@ aarch64_set_FP_long_double (sim_cpu *cpu, VReg reg, FRegister a)
>  #define GET_VEC_ELEMENT(REG, ELEMENT, FIELD)	   \
>    do						   \
>      {						   \
> -      if (element > ARRAY_SIZE (cpu->fr[0].FIELD)) \
> +      if (element >= ARRAY_SIZE (cpu->fr[0].FIELD)) \

s/element/ELEMENT/

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Commit: AArch64 sim: Fix off by one error checking for invalid vector array element
  2016-03-18 14:54 ` Andreas Schwab
@ 2016-03-18 17:10   ` Nick Clifton
  0 siblings, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2016-03-18 17:10 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gdb-patches

Hi Andreas,

>>   #define GET_VEC_ELEMENT(REG, ELEMENT, FIELD)	   \
>>     do						   \
>>       {						   \
>> +      if (element >= ARRAY_SIZE (cpu->fr[0].FIELD)) \
> 
> s/element/ELEMENT/

Doh!  Obvious fix checked in.  Thanks for spotting this.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-18 17:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-18 14:44 Commit: AArch64 sim: Fix off by one error checking for invalid vector array element Nick Clifton
2016-03-18 14:54 ` Andreas Schwab
2016-03-18 17:10   ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox