diff mbox series

[u-boot-mvebu,v2,21/41] tools: dumpimage: Fix crashing when trying to extract data from kwbimage

Message ID 20210719122104.29698-22-marek.behun@nic.cz
State Superseded
Delegated to: Stefan Roese
Headers show
Series kwboot / kwbimage improvements reducing image size | expand

Commit Message

Marek Behún July 19, 2021, 12:20 p.m. UTC
From: Pali Rohár <pali@kernel.org>

Trying to call the following command causes NULL pointer dereference in
strlen():
  ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb

Fix it by checking whether params->imagename is non-NULL before calling
strlen().

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
---
 tools/kwbimage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Roese July 21, 2021, 9:38 a.m. UTC | #1
On 19.07.21 14:20, Marek Behún wrote:
> From: Pali Rohár <pali@kernel.org>
> 
> Trying to call the following command causes NULL pointer dereference in
> strlen():
>    ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb
> 
> Fix it by checking whether params->imagename is non-NULL before calling
> strlen().
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   tools/kwbimage.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index f3b16d94ad..5410df63f5 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1867,7 +1867,7 @@ static int kwbimage_generate(struct image_tool_params *params,
>    */
>   static int kwbimage_check_params(struct image_tool_params *params)
>   {
> -	if (!strlen(params->imagename)) {
> +	if (!params->imagename || !strlen(params->imagename)) {
>   		char *msg = "Configuration file for kwbimage creation omitted";
>   
>   		fprintf(stderr, "Error:%s - %s\n", params->cmdname, msg);
> 


Viele Grüße,
Stefan
diff mbox series

Patch

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index f3b16d94ad..5410df63f5 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1867,7 +1867,7 @@  static int kwbimage_generate(struct image_tool_params *params,
  */
 static int kwbimage_check_params(struct image_tool_params *params)
 {
-	if (!strlen(params->imagename)) {
+	if (!params->imagename || !strlen(params->imagename)) {
 		char *msg = "Configuration file for kwbimage creation omitted";
 
 		fprintf(stderr, "Error:%s - %s\n", params->cmdname, msg);