2023-06-10 17:11:45

by Demi Marie Obenour

[permalink] [raw]
Subject: [PATCH v2 2/3] vsscanf(): do not skip spaces

Passing spaces before e.g. an integer is usually
not intended. This was suggested by Christoph in
https://lore.kernel.org/lkml/[email protected]/.

Suggested-by: Christoph Hellwig <[email protected]>
Signed-off-by: Demi Marie Obenour <[email protected]>
---
lib/vsprintf.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 8caccdcda0a2b470cda70c9b3837de37207eb512..d2d795d1aff0fd5cc50fb65ffb067067ab9f0dc6 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -3547,8 +3547,6 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
char *s = (char *)va_arg(args, char *);
if (field_width == -1)
field_width = SHRT_MAX;
- /* first, skip leading white space in buffer */
- str = skip_spaces(str);

/* now copy until next white space */
while (*str && !isspace(*str) && field_width--)
@@ -3635,11 +3633,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
return num;
}

- /* have some sort of integer conversion.
- * first, skip white space in buffer.
- */
- str = skip_spaces(str);
-
+ /* have some sort of integer conversion. */
digit = *str;
if (is_sign && digit == '-') {
if (field_width == 1)
--
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab