From aa5b4392aac99382d96be94782ae745e0a42484a Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 25 Jun 2014 20:25:28 +0200 Subject: [PATCH] estream: Fix minor glitch in "%.*s" format. * common/estream-printf.c (pr_string): Take care of non-nul terminated strings. --- common/estream-printf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/estream-printf.c b/common/estream-printf.c index 11e6d75fe..c03f70e3f 100644 --- a/common/estream-printf.c +++ b/common/estream-printf.c @@ -1209,7 +1209,9 @@ pr_string (estream_printf_out_t outfnc, void *outfncarg, string = "(null)"; if (arg->precision >= 0) { - for (n=0,s=string; *s && n < arg->precision; s++) + /* Test for nul after N so that we can pass a non-nul terminated + string. */ + for (n=0,s=string; n < arg->precision && *s; s++) n++; } else