From af8aef9ee241474c8764cb25319e17986cfb2ef6 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 28 Nov 2001 20:52:21 +0000 Subject: [PATCH] PyFloat_FromString(): Conversion of sprintf() to PyOS_snprintf() for buffer overrun avoidance. --- Objects/floatobject.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index cdc9620c020..02a1e1aa57e 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; }