]> git.ipfire.org Git - thirdparty/elfutils.git/commit
riscv_disasm.c: Fix out-of-bounds reads main
authorAaron Merey <amerey@redhat.com>
Mon, 1 Jun 2026 01:54:53 +0000 (21:54 -0400)
committerAaron Merey <amerey@redhat.com>
Tue, 2 Jun 2026 00:24:05 +0000 (20:24 -0400)
commit003d1c8bc8be6c45fc39eb1b886def17482ed3a5
tree40094927994cf1f26c9a1d2feeeeb9d597d9b410
parenta787c560dc3867a464e67a5c5a741739f9820470
riscv_disasm.c: Fix out-of-bounds reads

The riscv_disasm function reads instruction mnemonics from static
arrays based on the Control and Status Register (CSR) number encoded
in an instruction.  Two separate bounds checks performed before reading
from these arrays had incorrect upper bounds and allowed out-of-bounds
reads.

Fix two CSR bounds checks to prevent this. The affected CSR numbers that
are no longer included in the modified checks are now properly handled
in a generic CSR handler in the riscv_disasm function.

Signed-off-by: Aaron Merey <amerey@redhat.com>
libcpu/riscv_disasm.c