* [PATCH master] ARM: i.MX8M: HABv4: make barebox SHA256 embedding POSIX-shell compatible
@ 2022-08-15 6:38 Ahmad Fatoum
2022-08-15 6:46 ` Rouven Czerwinski
2022-08-16 6:34 ` Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-08-15 6:38 UTC (permalink / raw)
To: barebox; +Cc: rcz, Ahmad Fatoum
C-Style printf "\xHH" is not supported by a POSIX shell,
while printf "\oOOO" is. As we use printf "\xHH" for converting the
textual output of sha256sum into binary, systems using dash as shell
will end up embedding literal \xHH characters in the output resulting in
an ubootable barebox when CONFIG_PBL_VERIFY_PIGGY=y:
!hash mismatch, refusing to decompress
Fix this by using octal escape sequences instead.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
images/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/images/Makefile b/images/Makefile
index c79f1a272e9c..7a8bb94fe0df 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -113,7 +113,8 @@ $(obj)/piggy.o: $(obj)/barebox.z FORCE
$(obj)/sha_sum.o: $(obj)/barebox.sha.bin FORCE
quiet_cmd_sha256bin ?= SHA-BIN $@
- cmd_sha256bin ?= printf "$(shell awk '{printf $$1}' < $(obj)/barebox.sum | sed -e 's/../\\x&/g' )" > $@
+ cmd_sha256bin = printf "$(shell sed 's/ .*$$//;s/../0x&\n/g;s/\n$$//' $(obj)/barebox.sum | \
+ while read -r byte; do printf '\%o' $$byte; done)" > $@
quiet_cmd_sha256sum ?= SHA $@
cmd_sha256sum ?= sha256sum $(obj)/barebox.z > $@
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH master] ARM: i.MX8M: HABv4: make barebox SHA256 embedding POSIX-shell compatible
2022-08-15 6:38 [PATCH master] ARM: i.MX8M: HABv4: make barebox SHA256 embedding POSIX-shell compatible Ahmad Fatoum
@ 2022-08-15 6:46 ` Rouven Czerwinski
2022-08-16 6:34 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Rouven Czerwinski @ 2022-08-15 6:46 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Mon, 2022-08-15 at 08:38 +0200, Ahmad Fatoum wrote:
> C-Style printf "\xHH" is not supported by a POSIX shell,
> while printf "\oOOO" is. As we use printf "\xHH" for converting the
> textual output of sha256sum into binary, systems using dash as shell
> will end up embedding literal \xHH characters in the output resulting in
> an ubootable barebox when CONFIG_PBL_VERIFY_PIGGY=y:
>
> !hash mismatch, refusing to decompress
>
> Fix this by using octal escape sequences instead.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Reviewed-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
> images/Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/images/Makefile b/images/Makefile
> index c79f1a272e9c..7a8bb94fe0df 100644
> --- a/images/Makefile
> +++ b/images/Makefile
> @@ -113,7 +113,8 @@ $(obj)/piggy.o: $(obj)/barebox.z FORCE
> $(obj)/sha_sum.o: $(obj)/barebox.sha.bin FORCE
>
> quiet_cmd_sha256bin ?= SHA-BIN $@
> - cmd_sha256bin ?= printf "$(shell awk '{printf $$1}' < $(obj)/barebox.sum | sed -e 's/../\\x&/g' )" > $@
> + cmd_sha256bin = printf "$(shell sed 's/ .*$$//;s/../0x&\n/g;s/\n$$//' $(obj)/barebox.sum | \
> + while read -r byte; do printf '\%o' $$byte; done)" > $@
>
> quiet_cmd_sha256sum ?= SHA $@
> cmd_sha256sum ?= sha256sum $(obj)/barebox.z > $@
Best regards,
Rouven
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH master] ARM: i.MX8M: HABv4: make barebox SHA256 embedding POSIX-shell compatible
2022-08-15 6:38 [PATCH master] ARM: i.MX8M: HABv4: make barebox SHA256 embedding POSIX-shell compatible Ahmad Fatoum
2022-08-15 6:46 ` Rouven Czerwinski
@ 2022-08-16 6:34 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-08-16 6:34 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, rcz
On Mon, Aug 15, 2022 at 08:38:53AM +0200, Ahmad Fatoum wrote:
> C-Style printf "\xHH" is not supported by a POSIX shell,
> while printf "\oOOO" is. As we use printf "\xHH" for converting the
> textual output of sha256sum into binary, systems using dash as shell
> will end up embedding literal \xHH characters in the output resulting in
> an ubootable barebox when CONFIG_PBL_VERIFY_PIGGY=y:
>
> !hash mismatch, refusing to decompress
>
> Fix this by using octal escape sequences instead.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> images/Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/images/Makefile b/images/Makefile
> index c79f1a272e9c..7a8bb94fe0df 100644
> --- a/images/Makefile
> +++ b/images/Makefile
> @@ -113,7 +113,8 @@ $(obj)/piggy.o: $(obj)/barebox.z FORCE
> $(obj)/sha_sum.o: $(obj)/barebox.sha.bin FORCE
>
> quiet_cmd_sha256bin ?= SHA-BIN $@
> - cmd_sha256bin ?= printf "$(shell awk '{printf $$1}' < $(obj)/barebox.sum | sed -e 's/../\\x&/g' )" > $@
> + cmd_sha256bin = printf "$(shell sed 's/ .*$$//;s/../0x&\n/g;s/\n$$//' $(obj)/barebox.sum | \
> + while read -r byte; do printf '\%o' $$byte; done)" > $@
>
> quiet_cmd_sha256sum ?= SHA $@
> cmd_sha256sum ?= sha256sum $(obj)/barebox.z > $@
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-16 6:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 6:38 [PATCH master] ARM: i.MX8M: HABv4: make barebox SHA256 embedding POSIX-shell compatible Ahmad Fatoum
2022-08-15 6:46 ` Rouven Czerwinski
2022-08-16 6:34 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox