mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-30245: Fix possible overflow when organize struct.pack_into error message (#1682)
This commit is contained in:
parent
cdb89cd72c
commit
aead53b6ee
4 changed files with 19 additions and 2 deletions
|
@ -1929,11 +1929,14 @@ s_pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames
|
|||
|
||||
/* Check boundaries */
|
||||
if ((buffer.len - offset) < soself->s_size) {
|
||||
assert(offset >= 0);
|
||||
assert(soself->s_size >= 0);
|
||||
|
||||
PyErr_Format(StructError,
|
||||
"pack_into requires a buffer of at least %zd bytes for "
|
||||
"pack_into requires a buffer of at least %zu bytes for "
|
||||
"packing %zd bytes at offset %zd "
|
||||
"(actual buffer size is %zd)",
|
||||
soself->s_size + offset,
|
||||
(size_t)soself->s_size + (size_t)offset,
|
||||
soself->s_size,
|
||||
offset,
|
||||
buffer.len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue