mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 07:47:50 +00:00
initramfs: avoid memcpy for hex header fields
newc/crc cpio headers contain a bunch of 8-character hexadecimal fields which we convert via simple_strtoul(), following memcpy() into a zero-terminated stack buffer. The new simple_strntoul() helper allows us to pass in max_chars=8 to avoid zero-termination and memcpy(). Signed-off-by: David Disseldorp <ddiss@suse.de> Link: https://lore.kernel.org/r/20250304061020.9815-5-ddiss@suse.de Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
fcc155008a
commit
a8a3bc2e32
@@ -189,14 +189,11 @@ static __initdata u32 hdr_csum;
|
||||
static void __init parse_header(char *s)
|
||||
{
|
||||
unsigned long parsed[13];
|
||||
char buf[9];
|
||||
int i;
|
||||
|
||||
buf[8] = '\0';
|
||||
for (i = 0, s += 6; i < 13; i++, s += 8) {
|
||||
memcpy(buf, s, 8);
|
||||
parsed[i] = simple_strtoul(buf, NULL, 16);
|
||||
}
|
||||
for (i = 0, s += 6; i < 13; i++, s += 8)
|
||||
parsed[i] = simple_strntoul(s, NULL, 16, 8);
|
||||
|
||||
ino = parsed[0];
|
||||
mode = parsed[1];
|
||||
uid = parsed[2];
|
||||
|
||||
Reference in New Issue
Block a user