Skip to content

Commit ffe2643

Browse files
committed
gh-152718: Tighten comments and shorten the NEWS entry
1 parent 6e1023c commit ffe2643

3 files changed

Lines changed: 2 additions & 7 deletions

File tree

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
Fix unbounded memory allocation in the :mod:`profiling.sampling` binary profile
2-
reader, which trusted the string and frame table counts declared in a file's
3-
footer before allocating. A malformed file can no longer make the reader
4-
attempt a huge allocation.
2+
reader when a file declares more string or frame entries than it contains.

Modules/_remote_debugging/binary_io.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ static_assert(SAMPLE_HEADER_FIXED_SIZE == 13,
9191
static_assert(FILE_FOOTER_SIZE == 32,
9292
"FILE_FOOTER_SIZE must remain 32");
9393

94-
/* Minimum on-disk bytes per table entry: a string is a >=1-byte length
95-
* varint; a frame is six >=1-byte varints plus the opcode byte. */
94+
/* Minimum on-disk bytes of a string (1) and frame (7) table entry. */
9695
#define MIN_STRING_ENTRY_SIZE 1
9796
#define MIN_FRAME_ENTRY_SIZE 7
9897

Modules/_remote_debugging/binary_io_reader.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ reader_decompress_samples(BinaryReader *reader, const uint8_t *data)
240240
static inline int
241241
reader_parse_string_table(BinaryReader *reader, const uint8_t *data, size_t file_size)
242242
{
243-
/* Reject a count larger than the remaining bytes can hold. */
244243
size_t max_strings =
245244
(file_size - reader->string_table_offset) / MIN_STRING_ENTRY_SIZE;
246245
if (reader->strings_count > max_strings) {
@@ -290,7 +289,6 @@ reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, size_t file_
290289
}
291290
#endif
292291

293-
/* Reject a count larger than the remaining bytes can hold. */
294292
size_t max_frames =
295293
(file_size - reader->frame_table_offset) / MIN_FRAME_ENTRY_SIZE;
296294
if (reader->frames_count > max_frames) {

0 commit comments

Comments
 (0)