mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Merge in release25-maint r60793:
Added checks for integer overflows, contributed by Google. Some are only available if asserts are left in the code, in cases where they can't be triggered from Python code.
This commit is contained in:
parent
73baefd7fc
commit
9d53457e59
24 changed files with 438 additions and 54 deletions
|
@ -207,7 +207,10 @@ PyBuffer_New(Py_ssize_t size)
|
|||
"size must be zero or positive");
|
||||
return NULL;
|
||||
}
|
||||
/* XXX: check for overflow in multiply */
|
||||
if (sizeof(*b) > PY_SSIZE_T_MAX - size) {
|
||||
/* unlikely */
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
/* Inline PyObject_New */
|
||||
o = (PyObject *)PyObject_MALLOC(sizeof(*b) + size);
|
||||
if ( o == NULL )
|
||||
|
@ -401,6 +404,8 @@ buffer_concat(PyBufferObject *self, PyObject *other)
|
|||
if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 )
|
||||
return NULL;
|
||||
|
||||
assert(count <= PY_SIZE_MAX - size);
|
||||
|
||||
ob = PyString_FromStringAndSize(NULL, size + count);
|
||||
if ( ob == NULL )
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue