docs/180767: [man][libc] printf.3: fix off-by-one in snprintf description
Benjamin Kaduk
kaduk at MIT.EDU
Tue Jul 23 21:10:03 UTC 2013
The following reply was made to PR docs/180767; it has been noted by GNATS.
From: Benjamin Kaduk <kaduk at MIT.EDU>
To: bug-followup at freebsd.org
Cc:
Subject: Re: docs/180767: [man][libc] printf.3: fix off-by-one in snprintf
description
Date: Tue, 23 Jul 2013 17:07:02 -0400 (EDT)
On Tue, 23 Jul 2013, Dmitry Marakasov wrote:
>
>
>> Description:
> printf(3) says for snprintf:
>
> The snprintf() and vsnprintf() functions will write at most size-1 of the
> characters printed into the output string (the size'th character then
> gets the terminating `\0');
>
> the part in parenteses is incorrect: size'th character is outside
> buffer of [size] characters. It should instead say "(size-1)'th
> character" (which is last in the buffer).
I think one could argue either way. The character with index (size-1)
gets the NUL byte, but if one says that the first character is the one
with index 0, then it is in fact the size'th character which receives the
NUL.
-Ben Kaduk
More information about the freebsd-doc
mailing list