[PATCH v2 2/2] spl: spl_legacy: Fix printing image name

Michal Suchanek msuchanek at suse.de
Thu Oct 13 10:16:57 CEST 2022


image_set_name does not terminate the name in the image header.

Then is should not be assumed it's nul terminated. image_print_contents
correctly print only IH_NMLEN characters.

Fix printing the unterminated field in spl_parse_legacy_header. The
format specifies the minimum printed length, not maximum.

Signed-off-by: Michal Suchanek <msuchanek at suse.de>
Reviewed-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

---
 common/spl/spl_legacy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl_legacy.c b/common/spl/spl_legacy.c
index b3624dfbb7..11c459254b 100644
--- a/common/spl/spl_legacy.c
+++ b/common/spl/spl_legacy.c
@@ -55,7 +55,7 @@ int spl_parse_legacy_header(struct spl_image_info *spl_image,
 	spl_image->os = image_get_os(header);
 	spl_image->name = image_get_name(header);
 	debug(SPL_TPL_PROMPT
-	      "payload image: %32s load addr: 0x%lx size: %d\n",
+	      "payload image: %.*s load addr: 0x%lx size: %d\n", IH_NMLEN,
 	      spl_image->name, spl_image->load_addr, spl_image->size);
 
 	return 0;
-- 
2.37.3



More information about the U-Boot mailing list