Date: Tue, 23 Jul 2013 21:10:02 GMT From: Benjamin Kaduk <kaduk@MIT.EDU> To: freebsd-doc@FreeBSD.org Subject: Re: docs/180767: [man][libc] printf.3: fix off-by-one in snprintf description Message-ID: <201307232110.r6NLA2Xv093328@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR docs/180767; it has been noted by GNATS. From: Benjamin Kaduk <kaduk@MIT.EDU> To: bug-followup@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 Kadukhelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307232110.r6NLA2Xv093328>
