Skip to content

Commit fcc1550

Browse files
ddissbrauner
authored andcommitted
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>
1 parent 83c0b27 commit fcc1550

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

include/linux/kstrtox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t
143143
*/
144144

145145
extern unsigned long simple_strtoul(const char *,char **,unsigned int);
146+
extern unsigned long simple_strntoul(const char *,char **,unsigned int,size_t);
146147
extern long simple_strtol(const char *,char **,unsigned int);
147148
extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
148149
extern long long simple_strtoll(const char *,char **,unsigned int);

lib/vsprintf.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
114114
}
115115
EXPORT_SYMBOL(simple_strtoul);
116116

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+
117124
/**
118125
* simple_strtol - convert a string to a signed long
119126
* @cp: The start of the string

0 commit comments

Comments
 (0)