summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2014-11-06 19:28:38 +1100
committerAndrew Tridgell <tridge@samba.org>2014-11-06 19:29:17 +1100
commita50f687344f5bc54de2ca12801d46fb96f5d4b62 (patch)
treedfc88c19f05cf944ddf127485e90f905b2eb0a98
parent5ee4b2b2c26bbc35d1669840f0676e8aa383b984 (diff)
downloadnuttx-a50f687344f5bc54de2ca12801d46fb96f5d4b62.tar.gz
nuttx-a50f687344f5bc54de2ca12801d46fb96f5d4b62.tar.bz2
nuttx-a50f687344f5bc54de2ca12801d46fb96f5d4b62.zip
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.
-rw-r--r--nuttx/libc/stdio/lib_sscanf.c4
1 files changed, 4 insertions, 0 deletions
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 */