From e721d542eebdbf07331523c8d5cf1f7f30445ff4 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 1 Feb 2009 19:42:48 +0000 Subject: [PATCH] Fixed a possible invalid read when string is not null terminated --- main/spprintf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/spprintf.c b/main/spprintf.c index 704230d33d..aeecc6ca70 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -547,9 +547,11 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap) case 'v': s = va_arg(ap, char *); if (s != NULL) { - s_len = strlen(s); - if (adjust_precision && precision < s_len) + if (adjust_precision && precision) { s_len = precision; + } else { + s_len = strlen(s); + } } else { s = S_NULL; s_len = S_NULL_LEN; -- 2.40.0