Fix heap buffer overflow in op_cksm function (#2096)

* Fix heap-buffer-overflow in op_cksm function

* Update header
This commit is contained in:
Shivam7-1
2025-02-10 12:27:08 +05:30
committed by GitHub
parent e166cd93bb
commit ada8091ccc

View File

@@ -28,6 +28,8 @@
# define LOG_DISAS(...) do { } while (0) # define LOG_DISAS(...) do { } while (0)
#endif #endif
#define NUM_REGS 16
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "cpu.h" #include "cpu.h"
#include "internal.h" #include "internal.h"
@@ -2090,6 +2092,12 @@ static DisasJumpType op_cksm(DisasContext *s, DisasOps *o)
int r2 = get_field(s, r2); int r2 = get_field(s, r2);
TCGv_i64 len = tcg_temp_new_i64(tcg_ctx); TCGv_i64 len = tcg_temp_new_i64(tcg_ctx);
if (r2 < 0 || r2 + 1 >= NUM_REGS) {
// Handle invalid r2 index
tcg_temp_free_i64(tcg_ctx, len);
return DISAS_NORETURN;
}
gen_helper_cksm(tcg_ctx, len, tcg_ctx->cpu_env, o->in1, o->in2, tcg_ctx->regs[r2 + 1]); gen_helper_cksm(tcg_ctx, len, tcg_ctx->cpu_env, o->in1, o->in2, tcg_ctx->regs[r2 + 1]);
set_cc_static(s); set_cc_static(s);
return_low128(tcg_ctx, o->out); return_low128(tcg_ctx, o->out);