|
From: openocd-gerrit <ope...@us...> - 2022-12-17 09:32:38
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via a51ac964c6160646f2c28db854aa8faf096eb314 (commit)
from a6b02219529d1d48d130e4bed9c8d55395662ff6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a51ac964c6160646f2c28db854aa8faf096eb314
Author: Antonio Borneo <bor...@gm...>
Date: Sun Dec 11 10:11:58 2022 +0100
target: fix unsigned computation in 'monitor profile'
The implementation of command 'monitor profile' has few
issues:
- the address_space is a signed int, so cannot wrap-around on
space over INT_MAX;
- max address is incremented without check for overflow;
- assert() used on errors instead of returning error codes;
- only handles 32 bits PC;
- output file created and left empty on error.
This patch fixes the first two issues, as a wider fix would be too
invasive and should be postponed in a following series.
Change-Id: Id8ead3f6db0fd5730682a0d1638f11836d06a632
Signed-off-by: Antonio Borneo <bor...@gm...>
Fixes: https://sourceforge.net/p/openocd/tickets/370/
Reviewed-on: https://review.openocd.org/c/openocd/+/7394
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index e4fe20f72..755a8e283 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4251,10 +4251,11 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
/* max should be (largest sample + 1)
* Refer to binutils/gprof/hist.c (find_histogram_for_pc) */
- max++;
+ if (max < UINT32_MAX)
+ max++;
}
- int address_space = max - min;
+ uint32_t address_space = max - min;
assert(address_space >= 2);
/* FIXME: What is the reasonable number of buckets?
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|