From: Johan 't Hart Date: Fri, 21 Aug 2009 21:18:40 GMT Subject: Re: [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Message-ID: <4A8F0F30.3020002@gmail.com> In-Reply-To: <7vr5v4dgz0.fsf@alter.siamese.dyndns.org> Junio C Hamano schreef: > Marius Storm-Olsen writes: > >> From: Frank Li >> >> The Microsoft C runtime's vsnprintf function does not add NUL at >> the end of the buffer. > So if my reading is correct, it is not about "does not add NUL at the end" > at all; it is "adds NUL beyond the end of given output buffer." > As far as I know, the windows implementation does not add a terminating NUL when the string to write is greater or equal to the given buffer size. Otherwise it does add the NUL. Same as for strncpy() on windows. In my experience the windows implementation does never write behind the given buffer, not even a terminating zero.