diff options
author | Marek Vasut <marex@denx.de> | 2020-05-01 17:40:25 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-05-04 07:26:57 -0400 |
commit | 20a154f95bfe0a3b5bfba90bea7f001c58217536 (patch) | |
tree | f01b3610a039c506f9367dd1fc2d8e45fc58f99c | |
parent | c693f212c5b0433b3a49a89d87cbff28bf78eb87 (diff) | |
download | u-boot-20a154f95bfe0a3b5bfba90bea7f001c58217536.tar.gz u-boot-20a154f95bfe0a3b5bfba90bea7f001c58217536.tar.bz2 u-boot-20a154f95bfe0a3b5bfba90bea7f001c58217536.zip |
mkimage: fit: Do not tail-pad fitImage with external data
There is no reason to tail-pad fitImage with external data to 4-bytes,
while fitImage without external data does not have any such padding and
is often unaligned. DT spec also does not mandate any such padding.
Moreover, the tail-pad fills the last few bytes with uninitialized data,
which could lead to a potential information leak.
$ echo -n xy > /tmp/data ; \
./tools/mkimage -E -f auto -d /tmp/data /tmp/fitImage ; \
hexdump -vC /tmp/fitImage | tail -n 3
before:
00000260 61 2d 6f 66 66 73 65 74 00 64 61 74 61 2d 73 69 |a-offset.data-si|
00000270 7a 65 00 00 78 79 64 64 |ze..xydd|
^^ ^^ ^^
after:
00000260 61 2d 6f 66 66 73 65 74 00 64 61 74 61 2d 73 69 |a-offset.data-si|
00000270 7a 65 00 78 79 |ze.xy|
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Tom Rini <trini@konsulko.com>
-rw-r--r-- | tools/fit_image.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c index 88ff093d05..1e0f1e9fce 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -435,7 +435,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) int image_number; int align_size; - align_size = params->bl_len ? params->bl_len : 4; + align_size = params->bl_len ? params->bl_len : 1; fd = mmap_fdt(params->cmdname, fname, 0, &fdt, &sbuf, false, false); if (fd < 0) return -EIO; @@ -493,7 +493,6 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) fdt_pack(fdt); new_size = fdt_totalsize(fdt); - new_size = ALIGN(new_size, align_size); fdt_set_totalsize(fdt, new_size); debug("Size reduced from %x to %x\n", fit_size, fdt_totalsize(fdt)); debug("External data size %x\n", buf_ptr); |