mirror of
https://github.com/python/cpython.git
synced 2025-07-16 15:55:18 +00:00
Issue #26198: ValueError is now raised instead of TypeError on buffer
overflow in parsing "es#" and "et#" format units. SystemError is now raised instead of TypeError on programmical error in parsing format string.
This commit is contained in:
parent
3e17c788a8
commit
4cd63ef67a
4 changed files with 20 additions and 8 deletions
|
@ -394,7 +394,12 @@ seterror(Py_ssize_t iarg, const char *msg, int *levels, const char *fname,
|
|||
PyOS_snprintf(p, sizeof(buf) - (p - buf), " %.256s", msg);
|
||||
message = buf;
|
||||
}
|
||||
PyErr_SetString(PyExc_TypeError, message);
|
||||
if (msg[0] == '(') {
|
||||
PyErr_SetString(PyExc_SystemError, message);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1129,7 +1134,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
} else {
|
||||
if (size + 1 > BUFFER_LEN) {
|
||||
Py_DECREF(s);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"encoded string too long "
|
||||
"(%zd, maximum length %zd)",
|
||||
(Py_ssize_t)size, (Py_ssize_t)(BUFFER_LEN-1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue