mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-11-17 09:41:46 +00:00
Guard two more short-payload reads in TS parsing
Both were found while verifying #2349 and are reachable from stream data: - parse_SDT passes section_length - 4 - 8 to the services loop, and section_length comes from the stream. Below 12 (the smallest legal section: 8 bytes of fields plus the CRC) the unsigned subtraction wraps and the loop reads past the buffer. It got past both existing length checks. - read_video_pes_header reads the PES length and nextheader[6] before its own sbuflen < 9 check. With #2349 stopping the earlier crash in ts_readstream, a capbuf holding only a 3-byte start code now reaches it when flushed at EOF and is read past its end. Return -1 for a caller buffer shorter than 7 bytes, as the < 9 path already does.
This commit is contained in:
@@ -295,6 +295,13 @@ int read_video_pes_header(struct ccx_demuxer *ctx, struct demuxer_data *data, un
|
||||
// Read the next video PES
|
||||
// ((nextheader[3]&0xf0)==0xe0)
|
||||
long long result;
|
||||
|
||||
// A caller-supplied buffer must hold the PES length and nextheader[6]
|
||||
// before either is read; a truncated packet can leave fewer bytes.
|
||||
if (sbuflen > 0 && sbuflen < 7)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
unsigned peslen = nextheader[4] << 8 | nextheader[5];
|
||||
unsigned payloadlength = 0; // Length of packet data bytes
|
||||
static LLONG current_pts_33 = 0; // Last PTS from the header, without rollover bits
|
||||
|
||||
@@ -985,7 +985,9 @@ void parse_SDT(struct ccx_demuxer *ctx)
|
||||
// | payload_start[4]);
|
||||
// unsigned version_number = (payload_start[5] & 0x3E) >> 1;
|
||||
|
||||
if (section_length > payload_length - 4)
|
||||
// 12 is the smallest legal section: 8 bytes of fields plus the CRC.
|
||||
// Anything shorter would make the services loop length below underflow.
|
||||
if (section_length < 12 || section_length > payload_length - 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user