[issue2588] PyOS_vsnprintf() underflow leads to memory corruption

Justin Ferguson report at bugs.python.org
Wed Apr 9 03:21:18 CEST 2008


Justin Ferguson <justin.ferguson at ioactive.com> added the comment:

I do agree with your point about snprintf(..., sizeof(x), ...)-- my
single biggest point (and maybe i'm just not seeing it), is that there
appears to be no good reason for having this caveat and in turn its
essentially just code waiting to break; with as commonly used of a
function as it is, it's really a matter of when and not so much if.

While no one seems to ever use it this way, don't forget that a good
alternative to asprintf() is calling sprintf() with a length of zero to
get the length (in compliant implementations), allocating the memory and
then calling it again.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2588>
__________________________________


More information about the Python-bugs-list mailing list