From d55e44b2eaf88b046d85307c777252e344fbb57d Mon Sep 17 00:00:00 2001 From: Oleg Evseev Date: Sun, 19 Nov 2017 13:33:46 -0600 Subject: [PATCH] Fix sscanf character conversion (%c): do not add '\0' at the end as for strings, cause, for example, parsing one character will fill two bytes: character itself and zero one '\0' after it, so will overflow one byte variable argument and corrupt memory for variables allocated after it. --- libc/stdio/lib_sscanf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libc/stdio/lib_sscanf.c b/libc/stdio/lib_sscanf.c index 72dca128bd9..183b9b65357 100644 --- a/libc/stdio/lib_sscanf.c +++ b/libc/stdio/lib_sscanf.c @@ -574,7 +574,6 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap) if (!noassign) { strncpy(tv, buf, width); - tv[width] = '\0'; count++; }