Skip to content

Commit 6692aec

Browse files
committed
MAX_REMOTE_READ
1 parent 23df283 commit 6692aec

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

Modules/_remote_debugging/_remote_debugging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ typedef enum _WIN32_THREADSTATE {
144144
#define SIZEOF_INTERPRETER_STATE sizeof(PyInterpreterState)
145145

146146
/* Maximum sizes for validation to prevent buffer overflows from corrupted data */
147-
#define REMOTE_READ_SANITY_LIMIT ((Py_ssize_t)(256 * 1024)) /* 256 KB max for variable-length object reads */
147+
#define MAX_REMOTE_READ ((Py_ssize_t)(256 * 1024)) /* 256 KB max for variable-length object reads */
148148
#define MAX_STACK_CHUNK_SIZE (16 * 1024 * 1024) /* 16 MB max for stack chunks */
149149
#define MAX_LONG_DIGITS 64 /* Allows values up to ~2^1920 */
150150
#define MAX_SET_TABLE_SIZE (1 << 20) /* 1 million entries max for set iteration */

Modules/_remote_debugging/code_objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ parse_code_object(RemoteUnwinderObject *unwinder,
418418

419419
linetable = read_py_bytes(unwinder,
420420
GET_MEMBER(uintptr_t, code_object, unwinder->debug_offsets.code_object.linetable),
421-
REMOTE_READ_SANITY_LIMIT);
421+
MAX_REMOTE_READ);
422422
if (!linetable) {
423423
if (_Py_RemoteDebug_IsFatalReadError()) {
424424
set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read linetable from code object");

Modules/_remote_debugging/object_reading.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ read_py_str(
6464
}
6565

6666
Py_ssize_t len = GET_MEMBER(Py_ssize_t, unicode_obj, unwinder->debug_offsets.unicode_object.length);
67-
if (len < 0 || len > REMOTE_READ_SANITY_LIMIT) {
67+
if (len < 0 || len > MAX_REMOTE_READ) {
6868
PyErr_Format(PyExc_RuntimeError,
6969
"Invalid string length (%zd) at 0x%lx", len, address);
7070
set_exception_cause(unwinder, PyExc_RuntimeError, "Invalid string length in remote Unicode object");

0 commit comments

Comments
 (0)