diff mbox series

common: fit-sig: Fix error message in fit_config_verify_sig()

Message ID 20210111144658.620037-1-mr.nuke.me@gmail.com
State Accepted
Commit 76c78a548144b69ecc3ed9cc2d670297983da6b1
Delegated to: Tom Rini
Headers show
Series common: fit-sig: Fix error message in fit_config_verify_sig() | expand

Commit Message

Alexandru Gagniuc Jan. 11, 2021, 2:46 p.m. UTC
In fit_config_verify_sig(), when no 'signature*' subnode exists in
the configuration node, the fdt_for_each_subnode() loop is a no-op.
Therefore, no error flags are set, and 'err_,sg' is not populated
with an error string. This is incorrect behavior.

Populate err_msg to indicate that no 'signature' is found, before
entering the loop. The first call to fit_image_verify_sig() will
override clear err_msg, or set it to a more specific message.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
 common/image-fit-sig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Jan. 13, 2021, 4:10 p.m. UTC | #1
On Mon, 11 Jan 2021 at 07:47, Alexandru Gagniuc <mr.nuke.me@gmail.com> wrote:
>
> In fit_config_verify_sig(), when no 'signature*' subnode exists in
> the configuration node, the fdt_for_each_subnode() loop is a no-op.
> Therefore, no error flags are set, and 'err_,sg' is not populated
> with an error string. This is incorrect behavior.
>
> Populate err_msg to indicate that no 'signature' is found, before
> entering the loop. The first call to fit_image_verify_sig() will
> override clear err_msg, or set it to a more specific message.
>
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> ---
>  common/image-fit-sig.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Jan. 28, 2021, 11:57 p.m. UTC | #2
On Mon, Jan 11, 2021 at 08:46:58AM -0600, Alexandru Gagniuc wrote:

> In fit_config_verify_sig(), when no 'signature*' subnode exists in
> the configuration node, the fdt_for_each_subnode() loop is a no-op.
> Therefore, no error flags are set, and 'err_,sg' is not populated
> with an error string. This is incorrect behavior.
> 
> Populate err_msg to indicate that no 'signature' is found, before
> entering the loop. The first call to fit_image_verify_sig() will
> override clear err_msg, or set it to a more specific message.
> 
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/image-fit-sig.c b/common/image-fit-sig.c
index 7fcbb47235..f8a68b08dc 100644
--- a/common/image-fit-sig.c
+++ b/common/image-fit-sig.c
@@ -374,7 +374,7 @@  static int fit_config_verify_sig(const void *fit, int conf_noffset,
 				 const void *sig_blob, int sig_offset)
 {
 	int noffset;
-	char *err_msg = "";
+	char *err_msg = "No 'signature' subnode found";
 	int verified = 0;
 	int ret;