Blame 0017-target-arm-Fix-potential-buffer-overflow.patch

5544c1
From e7c3f6b4365f3162f8e25d58f76410aca28719a2 Mon Sep 17 00:00:00 2001
5544c1
From: Stefan Weil <sw@weilnetz.de>
5544c1
Date: Tue, 4 Sep 2012 07:35:57 +0200
5544c1
Subject: [PATCH] target-arm: Fix potential buffer overflow
5544c1
5544c1
Report from smatch:
5544c1
5544c1
target-arm/helper.c:651 arm946_prbs_read(6) error:
5544c1
 buffer overflow 'env->cp15.c6_region' 8 <= 8
5544c1
target-arm/helper.c:661 arm946_prbs_write(6) error:
5544c1
 buffer overflow 'env->cp15.c6_region' 8 <= 8
5544c1
5544c1
c7_region is an array with 8 elements, so the index must be less than 8.
5544c1
5544c1
Signed-off-by: Stefan Weil <sw@weilnetz.de>
5544c1
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5544c1
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 target-arm/helper.c | 4 ++--
5544c1
 1 file changed, 2 insertions(+), 2 deletions(-)
5544c1
5544c1
diff --git a/target-arm/helper.c b/target-arm/helper.c
5544c1
index dceaa95..e27df96 100644
5544c1
--- a/target-arm/helper.c
5544c1
+++ b/target-arm/helper.c
5544c1
@@ -645,7 +645,7 @@ static int pmsav5_insn_ap_read(CPUARMState *env, const ARMCPRegInfo *ri,
5544c1
 static int arm946_prbs_read(CPUARMState *env, const ARMCPRegInfo *ri,
5544c1
                             uint64_t *value)
5544c1
 {
5544c1
-    if (ri->crm > 8) {
5544c1
+    if (ri->crm >= 8) {
5544c1
         return EXCP_UDEF;
5544c1
     }
5544c1
     *value = env->cp15.c6_region[ri->crm];
5544c1
@@ -655,7 +655,7 @@ static int arm946_prbs_read(CPUARMState *env, const ARMCPRegInfo *ri,
5544c1
 static int arm946_prbs_write(CPUARMState *env, const ARMCPRegInfo *ri,
5544c1
                              uint64_t value)
5544c1
 {
5544c1
-    if (ri->crm > 8) {
5544c1
+    if (ri->crm >= 8) {
5544c1
         return EXCP_UDEF;
5544c1
     }
5544c1
     env->cp15.c6_region[ri->crm] = value;
5544c1
-- 
5544c1
1.7.12.1
5544c1