mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-16 04:32:47 +02:00
avformat/mpegts: remove JPEG-XS early return on invalid header_size
new_pes_packet() moves a buffer with pkt->buf = pes->buffer before JPEG-XS validation. If header_size > pkt->size, an early return leaves pes->buffer as a stale alias of pkt->buf with refcount 1. Later, mpegts_read_packet() calls av_packet_unref(), freeing the buffer through pkt->buf. The flush loop then re-enters new_pes_packet() and dereferences the dangling pes->buffer; a second path hits it via av_buffer_unref() in handle_packets() after a seek. Drop the early return. The packet is delivered with AV_PKT_FLAG_CORRUPT set, matching the PES-size-mismatch case above, and the function falls through to the normal cleanup path. The else guards the header trim so pkt->data/pkt->size stay valid for the memset. Fixes: use after free Fixes regression since16f89d342e. Found-by: Nicholas Carlini <nicholas@carlini.com> (cherry picked from commit55bf0e6cd5) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
259ee609ac
commit
42692d0f57
@@ -1041,10 +1041,10 @@ static int new_pes_packet(PESContext *pes, AVPacket *pkt)
|
||||
"Invalid JPEG-XS header size %"PRIu32" > packet size %d\n",
|
||||
header_size, pkt->size);
|
||||
pes->flags |= AV_PKT_FLAG_CORRUPT;
|
||||
return AVERROR_INVALIDDATA;
|
||||
} else {
|
||||
pkt->data += header_size;
|
||||
pkt->size -= header_size;
|
||||
}
|
||||
pkt->data += header_size;
|
||||
pkt->size -= header_size;
|
||||
}
|
||||
|
||||
memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user