Skip to content

Commit ada8091

Browse files
authored
Fix heap buffer overflow in op_cksm function (#2096)
* Fix heap-buffer-overflow in op_cksm function * Update header
1 parent e166cd9 commit ada8091

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

qemu/target/s390x/translate.c

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
# define LOG_DISAS(...) do { } while (0)
2929
#endif
3030

31+
#define NUM_REGS 16
32+
3133
#include "qemu/osdep.h"
3234
#include "cpu.h"
3335
#include "internal.h"
@@ -2089,6 +2091,12 @@ static DisasJumpType op_cksm(DisasContext *s, DisasOps *o)
20892091
TCGContext *tcg_ctx = s->uc->tcg_ctx;
20902092
int r2 = get_field(s, r2);
20912093
TCGv_i64 len = tcg_temp_new_i64(tcg_ctx);
2094+
2095+
if (r2 < 0 || r2 + 1 >= NUM_REGS) {
2096+
// Handle invalid r2 index
2097+
tcg_temp_free_i64(tcg_ctx, len);
2098+
return DISAS_NORETURN;
2099+
}
20922100

20932101
gen_helper_cksm(tcg_ctx, len, tcg_ctx->cpu_env, o->in1, o->in2, tcg_ctx->regs[r2 + 1]);
20942102
set_cc_static(s);

0 commit comments

Comments
 (0)