From fdef8aecb7f2dcf33d60a94be74b88193d26c1e9 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 11 Mar 2022 21:05:32 +0100 Subject: [PATCH] gdbstub: fix array overrun https://pvs-studio.com/en/blog/posts/cpp/0790/#ID487F9D1F5B Reported in https://github.com/espressif/esp-idf/issues/6440 --- components/esp_gdbstub/xtensa/gdbstub_xtensa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_gdbstub/xtensa/gdbstub_xtensa.c b/components/esp_gdbstub/xtensa/gdbstub_xtensa.c index 64c1436f6f..3d8723c092 100644 --- a/components/esp_gdbstub/xtensa/gdbstub_xtensa.c +++ b/components/esp_gdbstub/xtensa/gdbstub_xtensa.c @@ -117,7 +117,7 @@ void esp_gdbstub_tcb_to_regfile(TaskHandle_t tcb, esp_gdbstub_gdb_regfile_t *dst int esp_gdbstub_get_signal(const esp_gdbstub_frame_t *frame) { const char exccause_to_signal[] = {4, 31, 11, 11, 2, 6, 8, 0, 6, 7, 0, 0, 7, 7, 7, 7}; - if (frame->exccause > sizeof(exccause_to_signal)) { + if (frame->exccause >= sizeof(exccause_to_signal)) { return 11; } return (int) exccause_to_signal[frame->exccause];