avformat/spdifenc: bound DTS core_size against the packet size in the HD path

Fixes: out of array read
Fixes: yBSax492UIB9
Fixes: 482d98f69b (spdifenc: IEC 61937 encapsulation of DTS-HD for HDMI)
Found-by: Pavel Kohout (Aisle Research)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6f80e27654)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2026-06-30 00:11:50 +02:00
parent 2ec918330e
commit 385ac2fadc

View File

@@ -225,7 +225,7 @@ static int spdif_header_dts4(AVFormatContext *s, AVPacket *pkt, int core_size,
* (dtshd_fallback == 0) */
ctx->dtshd_skip = 1;
}
if (ctx->dtshd_skip && core_size) {
if (ctx->dtshd_skip && core_size && core_size <= pkt->size) {
pkt_size = core_size;
if (ctx->dtshd_fallback >= 0)
--ctx->dtshd_skip;