From a50f687344f5bc54de2ca12801d46fb96f5d4b62 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Nov 2014 19:28:38 +1100 Subject: lib_sscanf: fixed a hang in scanf() on end of string if we reach end of buffer when we are not on a format specifier then the code would loop forever. --- nuttx/libc/stdio/lib_sscanf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nuttx/libc/stdio/lib_sscanf.c b/nuttx/libc/stdio/lib_sscanf.c index 5c99ee47b..c1ad17323 100644 --- a/nuttx/libc/stdio/lib_sscanf.c +++ b/nuttx/libc/stdio/lib_sscanf.c @@ -699,6 +699,10 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap) buf++; } } + else { + /* it is not a format specifier, and buf is empty. Stop matching */ + break; + } } /* Clean up - read whitespaces */ -- cgit v1.2.3