All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] kwbimage: check return value of image_get_csk_index
@ 2021-08-17  5:11 Heinrich Schuchardt
  2021-08-17  6:47 ` Stefan Roese
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2021-08-17  5:11 UTC (permalink / raw)
  To: Tom Rini
  Cc: Marek Behún, Pali Rohár, Stefan Roese, Chris Packham,
	u-boot, Heinrich Schuchardt

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 <xypron.glpk@gmx.de>
---
 tools/kwbimage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 2a10df773b..bf7fd135ac 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;
 	}
--
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-01  9:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17  5:11 [PATCH 1/1] kwbimage: check return value of image_get_csk_index Heinrich Schuchardt
2021-08-17  6:47 ` Stefan Roese
2021-08-17  8:31 ` Pali Rohár
2021-09-01  9:14 ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.