Issue #14700: Fix buggy overflow checks for large precision and width in new-style and old-style formatting.

This commit is contained in:
Mark Dickinson 2012-10-28 10:00:46 +00:00
parent 08114d40e9
commit 75d3600466
7 changed files with 74 additions and 22 deletions

View file

@ -8394,7 +8394,7 @@ PyObject *PyUnicode_Format(PyObject *format,
c = *fmt++;
if (c < '0' || c > '9')
break;
if ((width*10) / 10 != width) {
if (width > (PY_SSIZE_T_MAX - ((int)c - '0')) / 10) {
PyErr_SetString(PyExc_ValueError,
"width too big");
goto onError;
@ -8427,7 +8427,7 @@ PyObject *PyUnicode_Format(PyObject *format,
c = *fmt++;
if (c < '0' || c > '9')
break;
if ((prec*10) / 10 != prec) {
if (prec > (INT_MAX - ((int)c - '0')) / 10) {
PyErr_SetString(PyExc_ValueError,
"prec too big");
goto onError;