[PATCH 1/1] kwbimage: check return value of image_get_csk_index
Pali Rohár
pali at kernel.org
Tue Aug 17 10:31:10 CEST 2021
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 at gmx.de>
Reviewed-by: Pali Rohár <pali at 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
>
More information about the U-Boot
mailing list