jtag/commands: fixed buffer overflow
commit179169268ca1bbac092324f597fbea090d75355e
authorSydMontague <sydmontague@phoenix-staffel.de>
Fri, 2 Feb 2024 11:12:48 +0000 (2 12:12 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 24 Feb 2024 13:41:06 +0000 (24 13:41 +0000)
tree7c05b6f7cba6dbeb30a1eeb0c7a369c3c24ca93b
parent33573cda4aa5685b32c44a81b1f2d84a28d78810
jtag/commands: fixed buffer overflow

When performing a command queue allocation larger than the default page
size of 1MiB any subsequent allocations will run into an integer under-
flow when checking for the remaining memory left in the current page.
Causing the function returning a pointer past the end of the buffer and
thus creating a buffer overflow.

This has been observed to cause some transfers to Efinix FPGAs to fail,
because another buffer can get corrupted in the process, causing its
respective free() to fail.

Change-Id: Ic5a0e1774e2dbd58f1a05127f14816c8251a7d9c
Signed-off-by: SydMontague <sydmontague@phoenix-staffel.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8126
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
src/jtag/commands.c