All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: "Tom Rini" <trini@konsulko.com>,
	"Marek Behún" <marek.behun@nic.cz>, "Stefan Roese" <sr@denx.de>,
	"Chris Packham" <judge.packham@gmail.com>,
	u-boot@lists.denx.de
Subject: Re: [PATCH 1/1] kwbimage: check return value of image_get_csk_index
Date: Tue, 17 Aug 2021 10:31:10 +0200	[thread overview]
Message-ID: <20210817083110.rzmyuwlpamvbq5nu@pali> (raw)
In-Reply-To: <20210817051158.13283-1-xypron.glpk@gmx.de>

On Tuesday 17 August 2021 07:11:58 Heinrich Schuchardt wrote:
> 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>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  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
> 

  parent reply	other threads:[~2021-08-17  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-09-01  9:14 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210817083110.rzmyuwlpamvbq5nu@pali \
    --to=pali@kernel.org \
    --cc=judge.packham@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=sr@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.