From: Ben Gras Date: Thu, 22 Jul 2010 22:35:44 +0000 (+0000) Subject: vsprintf: fix special yet useful case for vsprintf where n < 1. X-Git-Tag: v3.1.8~155 X-Git-Url: http://zhaoyanbai.com/repos/migration-4to9?a=commitdiff_plain;h=c4bb6abc2b61390468a6f68907d47dafaff407dd;p=minix.git vsprintf: fix special yet useful case for vsprintf where n < 1. reported by jaldhar. --- diff --git a/lib/libc/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c index 7f0cc2f9e..38b4964f3 100644 --- a/lib/libc/stdio/vsprintf.c +++ b/lib/libc/stdio/vsprintf.c @@ -21,8 +21,10 @@ vsnprintf(char *s, size_t n, const char *format, va_list arg) tmp_stream._count = n-1; retval = _doprnt(format, arg, &tmp_stream); - tmp_stream._count = 1; - (void) putc('\0',&tmp_stream); + if(n > 0) { + tmp_stream._count = 1; + (void) putc('\0',&tmp_stream); + } return retval; }