docs/180767: [man][libc] printf.3: fix off-by-one in snprintf description

Dmitry Marakasov amdmi3 at FreeBSD.org
Tue Jul 23 15:10:00 UTC 2013


>Number:         180767
>Category:       docs
>Synopsis:       [man][libc] printf.3: fix off-by-one in snprintf description
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 23 15:10:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Marakasov
>Release:        FreeBSD 9.1-RELEASE-p4 amd64
>Organization:
>Environment:
System: FreeBSD hades.panopticon 9.1-RELEASE-p4 FreeBSD 9.1-RELEASE-p4 #0 r251956: Tue Jun 18 21:41:37 MSK 2013 root at hades.panopticon:/usr/obj/usr/src/sys/HADES amd64


>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).

>How-To-Repeat:
>Fix:

--- printf.3.patch begins here ---
Index: lib/libc/stdio/printf.3
===================================================================
--- lib/libc/stdio/printf.3	(revision 253572)
+++ lib/libc/stdio/printf.3	(working copy)
@@ -143,7 +143,7 @@
 .Fa size Ns \-1
 of the characters printed into the output string
 (the
-.Fa size Ns 'th
+.Fa ( size Ns \-1)'th
 character then gets the terminating
 .Ql \e0 ) ;
 if the return value is greater than or equal to the
--- printf.3.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-doc mailing list