From: Heinrich Schuchardt Date: Tue, 17 Aug 2021 05:11:58 +0000 (+0200) Subject: kwbimage: check return value of image_get_csk_index X-Git-Url: http://git.dujemihanovic.xyz/login.html?a=commitdiff_plain;h=f0317d788221828089fe54433cf5c502d748ef77;p=u-boot.git kwbimage: check return value of image_get_csk_index image_get_csk_index() may return -1 in case of an error. Don't use this value as index. This resolves Coverity CID 338488 Memory - illegal accesses (NEGATIVE_RETURNS) Signed-off-by: Heinrich Schuchardt Reviewed-by: Stefan Roese Reviewed-by: Pali Rohár --- diff --git a/tools/kwbimage.c b/tools/kwbimage.c index b2694888d9..aa865cc443 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1087,7 +1087,7 @@ int kwb_sign_csk_with_kak(struct image_tool_params *params, int csk_idx = image_get_csk_index(); struct sig_v1 tmp_sig; - if (csk_idx >= 16) { + if (csk_idx < 0 || csk_idx > 15) { fprintf(stderr, "Invalid CSK index %d\n", csk_idx); return 1; }