mirror of https://github.com/python/cpython
Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking.
This commit is contained in:
parent
06c5c8a4d3
commit
22ccbbc4ec
|
@ -624,12 +624,12 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
ival = PyInt_AsLong(arg);
|
ival = PyInt_AsLong(arg);
|
||||||
if (ival == -1 && PyErr_Occurred())
|
if (ival == -1 && PyErr_Occurred())
|
||||||
return converterr("integer<i>", arg, msgbuf, bufsize);
|
return converterr("integer<i>", arg, msgbuf, bufsize);
|
||||||
else if (ival > INT_MAX) {
|
else if (ival > LONG_MAX) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"signed integer is greater than maximum");
|
"signed integer is greater than maximum");
|
||||||
return converterr("integer<i>", arg, msgbuf, bufsize);
|
return converterr("integer<i>", arg, msgbuf, bufsize);
|
||||||
}
|
}
|
||||||
else if (ival < INT_MIN) {
|
else if (ival < LONG_MIN) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"signed integer is less than minimum");
|
"signed integer is less than minimum");
|
||||||
return converterr("integer<i>", arg, msgbuf, bufsize);
|
return converterr("integer<i>", arg, msgbuf, bufsize);
|
||||||
|
|
Loading…
Reference in New Issue