summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-11-28 20:52:21 (GMT)
committerBarry Warsaw <barry@python.org>2001-11-28 20:52:21 (GMT)
commitaf8aef9ee241474c8764cb25319e17986cfb2ef6 (patch)
treeafc53d615a4f85934ace5b6b8abad60356005ced
parent01d697a06711d9070c459bc9f1028dd0abc79fab (diff)
downloadcpython-af8aef9ee241474c8764cb25319e17986cfb2ef6.zip
cpython-af8aef9ee241474c8764cb25319e17986cfb2ef6.tar.gz
cpython-af8aef9ee241474c8764cb25319e17986cfb2ef6.tar.bz2
PyFloat_FromString(): Conversion of sprintf() to PyOS_snprintf() for
buffer overrun avoidance.
-rw-r--r--Objects/floatobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index cdc9620..02a1e1a 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;
}