PyFloat_FromString(): Conversion of sprintf() to PyOS_snprintf() for

buffer overrun avoidance.
This commit is contained in:
Barry Warsaw 2001-11-28 20:52:21 +00:00
parent 01d697a067
commit af8aef9ee2
1 changed files with 4 additions and 2 deletions

View File

@ -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;
}