From bef4cc466bdca22eb2140c100f9704060c028315 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Tue, 30 Jul 2019 13:40:18 -0700 Subject: vprintf: fix handling % in the end of the format string EC vprintf() implementation treats a single '%' character in the end of the format string as a literal per cent character. This is a special case, while processing it the terminated zero is getting lost. This patch fixes the problem. BRANCH=none BUG=none TEST=none Change-Id: I9abea74072b56edfbbace988b0b7a6d1f7d8cd5f Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1726739 Reviewed-by: Andrey Pronin Reviewed-by: Randall Spangler --- common/printf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/printf.c b/common/printf.c index e673c17baa..f3b912b5c1 100644 --- a/common/printf.c +++ b/common/printf.c @@ -87,6 +87,10 @@ int vfnprintf(int (*addchar)(void *context, int c), void *context, if (c == '%' || c == '\0') { if (addchar(context, '%')) return EC_ERROR_OVERFLOW; + + if (c == '\0') + break; + continue; } -- cgit v1.2.1