summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-07-30 13:40:18 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-31 00:54:57 +0000
commitbef4cc466bdca22eb2140c100f9704060c028315 (patch)
treecb5019f238ed805e82cf505f97ffb04cb5c2e0c6
parent0bbe9193b17f6d6057b3ff3cc12af262e417f459 (diff)
downloadchrome-ec-bef4cc466bdca22eb2140c100f9704060c028315.tar.gz
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 <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1726739 Reviewed-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/printf.c4
1 files changed, 4 insertions, 0 deletions
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;
}