From: Vsevolod Stakhov Date: Fri, 16 Jan 2015 12:24:16 +0000 (+0000) Subject: Fix double format output. X-Git-Tag: 0.8.1~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=68724d418dd085781218f00a2a68ad586ea4707b;p=rspamd.git Fix double format output. --- diff --git a/src/libutil/printf.c b/src/libutil/printf.c index d43e38810..26fc174e8 100644 --- a/src/libutil/printf.c +++ b/src/libutil/printf.c @@ -411,8 +411,19 @@ rspamd_vprintf_common (rspamd_printf_append_func func, case '.': fmt++; - while (*fmt >= '0' && *fmt <= '9') { - frac_width = frac_width * 10 + *fmt++ - '0'; + if (*fmt == '*') { + d = (gint)va_arg (args, gint); + if (G_UNLIKELY (d < 0)) { + msg_err ("critical error: fraction width is less than 0"); + return 0; + } + frac_width = (guint)d; + fmt++; + } + else { + while (*fmt >= '0' && *fmt <= '9') { + frac_width = frac_width * 10 + *fmt++ - '0'; + } } break;