[openwrt/openwrt] mkimage: fix validation of legacy images with custom magic

LEDE Commits lede-commits at lists.infradead.org
Fri Aug 12 03:04:28 PDT 2022


dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/68cd4dc3ed6e50988bcc4f1eaeec9902677f109b

commit 68cd4dc3ed6e50988bcc4f1eaeec9902677f109b
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Fri Aug 12 12:02:04 2022 +0200

    mkimage: fix validation of legacy images with custom magic
    
    All images generated by mkimage are now always validated.
    This change broke our downstream support for setting a custom value for
    IH_MAGIC (mkimage -M ...). Make sure also plain legacy kernel images
    with custom value set for IH_MAGIC validate correctly.
    
    Fixes: fa9895ee5b ("tools: mkimage: update to U-Boot release 2022.07")
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 tools/mkimage/patches/030-allow-to-use-different-magic.patch | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
index 017f0b9b34..b97cd819cc 100644
--- a/tools/mkimage/patches/030-allow-to-use-different-magic.patch
+++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
@@ -50,6 +50,15 @@ This patch makes it possible to set a custom image magic.
  			break;
 --- a/tools/default_image.c
 +++ b/tools/default_image.c
+@@ -56,7 +56,7 @@ static int image_verify_header(unsigned
+ 	 */
+ 	memcpy(hdr, ptr, sizeof(image_header_t));
+ 
+-	if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
++	if (be32_to_cpu(hdr->ih_magic) != params->magic) {
+ 		debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
+ 		      params->cmdname, params->imagefile);
+ 		return -FDT_ERR_BADMAGIC;
 @@ -120,7 +120,7 @@ static void image_set_header(void *ptr,
  	}
  




More information about the lede-commits mailing list