[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-www
Subject:    Re: docs/180767: [man][libc] printf.3: fix off-by-one in snprintf description
From:       Benjamin Kaduk <kaduk () MIT ! EDU>
Date:       2013-07-23 21:10:02
Message-ID: 201307232110.r6NLA2Xv093328 () freefall ! freebsd ! org
[Download RAW message or body]

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 Kaduk
_______________________________________________
freebsd-doc@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-doc
To unsubscribe, send any mail to "freebsd-doc-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic