Re: [PATCH v1 2/4] initramfs: Refactor to use hex2bin() instead of custom approach
From: David Disseldorp
Date: Tue Jan 20 2026 - 15:12:55 EST
On Mon, 19 Jan 2026 21:38:39 +0100, Andy Shevchenko wrote:
> + ret = hex2bin((u8 *)header, s + 6, sizeof(header));
> + if (ret)
> + error("damaged header");
The changes look reasonable to me on first glance, but I think we really
should improve the error handling to abort the state machine on
malformed header here.
One further issue that we have is simple_strntoul()'s acceptance of
"0x" prefixes for the hex strings - any initramfs which carries such
prefixes will now result in an error.
It's a pretty obscure corner case, but cpio is really easy to generate
from printf(), so maybe there are some images out there which rely on
this.
I've written an initramfs_test regression test for the "0x" prefix
handling. I'll send it to the list.
Thanks, David