aboutsummaryrefslogtreecommitdiff
path: root/target-cris
diff options
context:
space:
mode:
authorzhanghailiang <zhang.zhanghailiang@huawei.com>2014-11-17 13:57:34 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2014-11-17 13:59:23 +0100
commitfae38221e78fc9f847965f6d18b359b8044df348 (patch)
treef34239a249594acc310c572682c63904d9fa9197 /target-cris
parent0e8b439ae57ee3c46fb95e1775ea038d34496346 (diff)
downloadqemu-arm-fae38221e78fc9f847965f6d18b359b8044df348.tar.gz
target-cris/translate.c: fix out of bounds read
In function t_gen_mov_TN_preg and t_gen_mov_preg_TN, The begin check about the validity of in-parameter 'r' is useless. We still access cpu_PR[r] in the follow code if it is invalid. Which will be an out-of-bounds read error. Fix it by using assert() to ensure it is valid before using it. Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target-cris')
-rw-r--r--target-cris/translate.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/target-cris/translate.c b/target-cris/translate.c
index e37b04e69d..76406af980 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -169,9 +169,7 @@ static int preg_sizes[] = {
static inline void t_gen_mov_TN_preg(TCGv tn, int r)
{
- if (r < 0 || r > 15) {
- fprintf(stderr, "wrong register read $p%d\n", r);
- }
+ assert(r >= 0 && r <= 15);
if (r == PR_BZ || r == PR_WZ || r == PR_DZ) {
tcg_gen_mov_tl(tn, tcg_const_tl(0));
} else if (r == PR_VR) {
@@ -182,9 +180,7 @@ static inline void t_gen_mov_TN_preg(TCGv tn, int r)
}
static inline void t_gen_mov_preg_TN(DisasContext *dc, int r, TCGv tn)
{
- if (r < 0 || r > 15) {
- fprintf(stderr, "wrong register write $p%d\n", r);
- }
+ assert(r >= 0 && r <= 15);
if (r == PR_BZ || r == PR_WZ || r == PR_DZ) {
return;
} else if (r == PR_SRS) {