Commit 55d96e4
fix(fseq): never read a frame into an UncompressedFrameData whose malloc failed
UncompressedFrameData's constructor does `m_data = (uint8_t*)malloc(sz)` and
does not check the result. readFrame() tests m_data for null, but none of the
five getFrame() implementations that fill the buffer do: they go straight to
`read(&data->m_data[sz], toRead)` or `memcpy(data->m_data, ...)`. When the
allocation fails, the read path becomes fread(NULL, 1, N, fp), which faults
inside glibc's own buffer copy - a memcpy crash with no FPP frame below it,
which is exactly the shape that makes these reports hard to bucket.
This is reachable, not theoretical. A channel range whose start lies past the
end of the sequence turns m_dataBlockSize into a ~4GB request; the range guard
in V1FSEQFile::prepareRead keeps master out of that particular hole, but the
allocation can still fail for its own reasons on a 512MB controller, and four
of the five call sites are in the V2 handlers, which compute the size their
own way.
Add one guard used by all five sites: log the size that could not be allocated
and hand the frame back untouched. Returning the object rather than nullptr
matches the existing early-exit paths in these functions, and readFrame()
already reports false for a null buffer, so callers see a frame that did not
load instead of a daemon that died.
Verified with a standalone harness that builds FSEQFile.cpp on its own and runs
it under a capped address space so malloc genuinely fails. The control fails
first: the same harness against a tree without the range guard segfaults inside
fread with buf=0x0, and with this change it logs the failed allocation and
returns a frame that readFrame() rejects.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 2ed5566 commit 55d96e4
1 file changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
731 | 744 | | |
732 | 745 | | |
733 | 746 | | |
| |||
767 | 780 | | |
768 | 781 | | |
769 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
770 | 786 | | |
771 | 787 | | |
772 | 788 | | |
| |||
885 | 901 | | |
886 | 902 | | |
887 | 903 | | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
888 | 907 | | |
889 | 908 | | |
890 | 909 | | |
| |||
1509 | 1528 | | |
1510 | 1529 | | |
1511 | 1530 | | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
1512 | 1534 | | |
1513 | 1535 | | |
1514 | 1536 | | |
| |||
1579 | 1601 | | |
1580 | 1602 | | |
1581 | 1603 | | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
1582 | 1607 | | |
1583 | 1608 | | |
1584 | 1609 | | |
| |||
1807 | 1832 | | |
1808 | 1833 | | |
1809 | 1834 | | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
1810 | 1838 | | |
1811 | 1839 | | |
1812 | 1840 | | |
| |||
0 commit comments