From: Barry Warsaw Date: Wed, 28 Nov 2001 20:52:21 +0000 (+0000) Subject: PyFloat_FromString(): Conversion of sprintf() to PyOS_snprintf() for X-Git-Tag: v2.2.1c1~673 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af8aef9ee241474c8764cb25319e17986cfb2ef6;p=python PyFloat_FromString(): Conversion of sprintf() to PyOS_snprintf() for buffer overrun avoidance. --- diff --git a/Objects/floatobject.c b/Objects/floatobject.c index cdc9620c02..02a1e1aa57 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -150,7 +150,8 @@ PyFloat_FromString(PyObject *v, char **pend) if (end > last) end = last; if (end == s) { - sprintf(buffer, "invalid literal for float(): %.200s", s); + PyOS_snprintf(buffer, sizeof(buffer), + "invalid literal for float(): %.200s", s); PyErr_SetString(PyExc_ValueError, buffer); return NULL; } @@ -159,7 +160,8 @@ PyFloat_FromString(PyObject *v, char **pend) while (*end && isspace(Py_CHARMASK(*end))) end++; if (*end != '\0') { - sprintf(buffer, "invalid literal for float(): %.200s", s); + PyOS_snprintf(buffer, sizeof(buffer), + "invalid literal for float(): %.200s", s); PyErr_SetString(PyExc_ValueError, buffer); return NULL; }