New submission from Windson Yang <[email protected]>:
In
[resize_buffer](https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Modules/_io/stringio.c#L85)
/* For simplicity, stay in the range of the signed type. Anyway, Python
doesn't allow strings to be longer than this. */
if (size > PY_SSIZE_T_MAX)
goto overflow;
...
IMO, we should check the overflow with
if (size > PY_SSIZE_T_MAX/sizeof(Py_UCS4))
Or we can just delete this code because we will check later at
[alloc_check](https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Modules/_io/stringio.c#L107)
BTW, I found we only use PY_SIZE_MAX here in CPython, I wonder why we do not
use PY_SSIZE_T_MAX instead?
----------
components: IO
messages: 327223
nosy: Windson Yang
priority: normal
severity: normal
status: open
title: Update overflow checks in resize_buffer
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34912>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com