This is an automated email from Gerrit. "Erhan Kurubas <erhan.kuru...@espressif.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7005
-- gerrit commit 97e0b324d9e9b136cd565c76ba7e73fdf6a428b6 Author: Erhan Kurubas <erhan.kuru...@espressif.com> Date: Sat May 28 08:30:21 2022 +0200 semihosting: fix accessing memory outside the bounds of the fn array There is an accsess to wrong index, when arm semihosting_basedir command not used or basedir set to empty string. Signed-off-by: Erhan Kurubas <erhan.kuru...@espressif.com> Change-Id: I3afa049d74b30496f5c03ba4ef67431784f81bdc diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c index 2df6e38aea..c9e1a5eb6f 100644 --- a/src/target/semihosting_common.c +++ b/src/target/semihosting_common.c @@ -878,7 +878,7 @@ int semihosting_common(struct target *target) semihosting->sys_errno = ENOMEM; } else { strncpy((char *)fn, semihosting->basedir, basedir_len); - if (fn[basedir_len - 1] != '/') + if (basedir_len > 0 && fn[basedir_len - 1] != '/') fn[basedir_len++] = '/'; retval = target_read_memory(target, addr, 1, len, fn + basedir_len); if (retval != ERROR_OK) { --