vsprintf considered dangerous

Roland McGrath rk9005 at cca.ucsf.edu
Mon Apr 4 12:30:07 AEST 1988


The GNU C library has such a function.  It's called "vsnprintf" and it
takes a maximum-length argument (there's also an "snprintf").
When I finish the GNU C library it will be freely distributed and you
can then use it.

In general, one should take care when using the sprintf functions.
Make sure you know the maximum length that the format specification
will produce and arrange to have at least that much space allocated.
-- 
	Roland McGrath
ARPA: roland at rtsg.lbl.gov roland at lbl-rtsg.arpa
UUCP: ...!ucbvax!lbl-rtsg.arpa!roland



More information about the Comp.lang.c mailing list