diff mbox series

image-host: Fix error value paths and emit error messages to stderr.

Message ID 20240123081556.418900-2-hugo.cornelis@essensium.com
State Changes Requested
Delegated to: Heinrich Schuchardt
Headers show
Series image-host: Fix error value paths and emit error messages to stderr. | expand

Commit Message

Hugo Cornelis Jan. 23, 2024, 8:15 a.m. UTC
Signed-off-by: Hugo Cornelis <hugo.cornelis@essensium.com>
---
 tools/image-host.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Heinrich Schuchardt Jan. 28, 2024, 8:36 a.m. UTC | #1
On 1/23/24 09:15, Hugo Cornelis wrote:

Thanks Hugo for addressing the issue. Could you, please, resend the
patch with an appropriate commit message. Please, use
scripts/get_maintainers.pl to determine the list of addressees.

Otherwise the patch looks good to me.

The initial assignment in fit_image_read_key_iv_data()

     int ret = -1;

is superfluous. You may want to fix that too

It helps to know which patch introduced the problem. Please, add

Fixes: bc01d9ff93f3 ("image-host: refactor and protect for very long
filenames")

Best regards

Heinrich

> Signed-off-by: Hugo Cornelis <hugo.cornelis@essensium.com>
> ---
>   tools/image-host.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/image-host.c b/tools/image-host.c
> index b2a0f2e6d1..06b05dcacb 100644
> --- a/tools/image-host.c
> +++ b/tools/image-host.c
> @@ -351,12 +351,12 @@ static int fit_image_read_key_iv_data(const char *keydir, const char *key_iv_nam
>   	ret = snprintf(filename, sizeof(filename), "%s/%s%s",
>   		       keydir, key_iv_name, ".bin");
>   	if (ret >= sizeof(filename)) {
> -		printf("Can't format the key or IV filename when setting up the cipher: insufficient buffer space\n");
> -		ret = -1;
> +		fprintf(stderr, "Can't format the key or IV filename when setting up the cipher: insufficient buffer space\n");
> +		return -1;
>   	}
>   	if (ret < 0) {
> -		printf("Can't format the key or IV filename when setting up the cipher: snprintf error\n");
> -		ret = -1;
> +		fprintf(stderr, "Can't format the key or IV filename when setting up the cipher: snprintf error\n");
> +		return -1;
>   	}
>
>   	ret = fit_image_read_data(filename, key_iv_data, expected_size);
diff mbox series

Patch

diff --git a/tools/image-host.c b/tools/image-host.c
index b2a0f2e6d1..06b05dcacb 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -351,12 +351,12 @@  static int fit_image_read_key_iv_data(const char *keydir, const char *key_iv_nam
 	ret = snprintf(filename, sizeof(filename), "%s/%s%s",
 		       keydir, key_iv_name, ".bin");
 	if (ret >= sizeof(filename)) {
-		printf("Can't format the key or IV filename when setting up the cipher: insufficient buffer space\n");
-		ret = -1;
+		fprintf(stderr, "Can't format the key or IV filename when setting up the cipher: insufficient buffer space\n");
+		return -1;
 	}
 	if (ret < 0) {
-		printf("Can't format the key or IV filename when setting up the cipher: snprintf error\n");
-		ret = -1;
+		fprintf(stderr, "Can't format the key or IV filename when setting up the cipher: snprintf error\n");
+		return -1;
 	}
 
 	ret = fit_image_read_data(filename, key_iv_data, expected_size);