| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
| } | ||
| #endif | ||
|
|
||
| size_t max_frames = |
There was a problem hiding this comment.
Wondering about a helper. With these two and this one:
cpython/Modules/_remote_debugging/binary_io_reader.c
Lines 1056 to 1066 in ecdef17
it'd be three. Something along the lines of reader_validate_count("RLE", count, reader->sample_data_size - offset, 2) etc.
Generally, wondering about centralizing all these validations in a single place.
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
…count Addresses review feedback: centralize the string/frame/RLE oversized-count validations behind one helper.
|
@tonghuaroot seems tests are failing can you take a look? |
Sorry, something went wrong.
On 32-bit builds a footer frame count of 0xFFFFFFFF overflows the allocation size, so the size_t overflow guard raises OverflowError before the count-vs-file-size guard raises ValueError. Accept either rejection.
|
Thanks @pablogsal, pushed a fix in 7c23d37. The failure was 32-bit only (Win32 and Emscripten): test_open_rejects_frame_count_larger_than_file patches the frame count to 0xFFFFFFFF, which on a 32-bit build overflows frames_count * sizeof(FrameEntry), so the pre-existing SIZEOF_SIZE_T < 8 guard raises OverflowError before the new count-vs-file-size check raises ValueError. Both reject the file, so I relaxed the test to accept either. Re-running CI now. |
Sorry, something went wrong.
|
Thanks @tonghuaroot for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
Sorry, something went wrong.
|
GH-153050 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This bounds the eager string-table and frame-table allocations in the
_remote_debugging binary profile reader against the file size before
allocating, so a .pyb file whose footer declares an oversized count is
rejected with a ValueError instead of triggering a multi-gigabyte allocation.
Each table entry occupies at least one byte on disk (a string is a >=1-byte
length varint, a frame is six >=1-byte varints plus the opcode byte), so a count
larger than (file_size - table_offset) / MIN_ENTRY_SIZE cannot be backed by
real data. This mirrors the existing RLE-count bound in binary_reader_replay.
Legitimate files are unaffected.
Regression tests in test_binary_format patch the footer counts and assert the
reader rejects both an oversized and a one-past-capacity count, while a count
exactly at the cap still opens.