From 0acef7729f664cfe591ff86964651bb0bbf5d6b0 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 20 May 2015 10:27:12 -0400 Subject: [PATCH] roken: fix append_string "%.s" non-nul termination It should be possible to pass a format string of "%.s" to permit a non-nul terminated string to be used as input. The test of remaining precision and the test for NUL needs to be reversed to permit this behavior to function correctly. Change-Id: I200f9c2886419dc4c3870f5f44bc10e81245f56c --- lib/roken/snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/roken/snprintf.c b/lib/roken/snprintf.c index 022118e53..add375b0f 100644 --- a/lib/roken/snprintf.c +++ b/lib/roken/snprintf.c @@ -276,7 +276,7 @@ append_string (struct snprintf_state *state, len += pad(state, width, ' '); if (prec != -1) { - while (*arg && prec--) { + while (prec== && *arg) { (*state->append_char) (state, *arg++); ++len; }