]> www.infradead.org Git - users/borneoa/openocd-next.git/commit
target: aarch64: fix out-of-bound access to array
authorAntonio Borneo <borneo.antonio@gmail.com>
Fri, 22 Nov 2024 17:06:40 +0000 (18:06 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 22 Dec 2024 09:50:50 +0000 (09:50 +0000)
commit42f70a3b95ea708d0e4fd5d83a6bc6965fd65ac6
treee876b55defeea7b7964979f41d03d7a9fda32aa3
parent1710954977a0262e6987426f117aab0f73b27024
target: aarch64: fix out-of-bound access to array

The command 'arm core_state' uses the enum in 'arm->core_state' as
an index in the table of strings to print the core state.

With [1] the enum has been extended with the new state for AArch64
but not the corresponding table of strings.
This causes an access after the limit of arm_state_strings[].

Rewrite the table using c99 array designators to better show the
link between the enum list and the table.
Add the function arm_core_state_string() to check for out-of-bound
values allover the file.

Change-Id: I06473c2c8088b38ee07118bcc9e49bc8eafbc6e2
Fixes: [1] 9cbfc9feb35c ("arm_dpm: Add new state ARM_STATE_AARCH64")
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8594
Tested-by: jenkins
src/target/armv4_5.c