Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vsprintf: add simple_strntoul

cpio extraction currently does a memcpy to ensure that the archive hex
fields are null terminated for simple_strtoul(). simple_strntoul() will
allow us to avoid the memcpy.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Link: https://lore.kernel.org/r/20250304061020.9815-4-ddiss@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

David Disseldorp and committed by
Christian Brauner
fcc15500 83c0b272

+8
+1
include/linux/kstrtox.h
··· 143 143 */ 144 144 145 145 extern unsigned long simple_strtoul(const char *,char **,unsigned int); 146 + extern unsigned long simple_strntoul(const char *,char **,unsigned int,size_t); 146 147 extern long simple_strtol(const char *,char **,unsigned int); 147 148 extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 148 149 extern long long simple_strtoll(const char *,char **,unsigned int);
+7
lib/vsprintf.c
··· 114 114 } 115 115 EXPORT_SYMBOL(simple_strtoul); 116 116 117 + unsigned long simple_strntoul(const char *cp, char **endp, unsigned int base, 118 + size_t max_chars) 119 + { 120 + return simple_strntoull(cp, endp, base, max_chars); 121 + } 122 + EXPORT_SYMBOL(simple_strntoul); 123 + 117 124 /** 118 125 * simple_strtol - convert a string to a signed long 119 126 * @cp: The start of the string