Commit 065cfa5497 for ffmpeg
commit 065cfa5497fb393c2579d8b67157c245b0b8b04e
Author: Richard Desmarais <richard.desmarais@gusto.com>
Date: Mon Nov 16 19:14:53 2026 -0500
avformat/mxfdec: Check reads in mxf_decrypt_triplet
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index a47a01812f..8b37aa31df 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -690,7 +690,9 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
plaintext_size = avio_rb64(pb);
// source klv key
klv_decode_ber_length(pb, NULL);
- avio_read(pb, klv->key, 16);
+ ret = ffio_read_size(pb, klv->key, 16);
+ if (ret < 0)
+ return ret;
if (!IS_KLV_KEY(klv, mxf_essence_element_key))
return AVERROR_INVALIDDATA;
@@ -707,9 +709,11 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
size = klv_decode_ber_length(pb, NULL);
if (size < 32 || size - 32 < orig_size || (int)orig_size != orig_size)
return AVERROR_INVALIDDATA;
- avio_read(pb, ivec, 16);
+ ret = ffio_read_size(pb, ivec, 16);
+ if (ret < 0)
+ return ret;
ret = ffio_read_size(pb, tmpbuf, 16);
- if (ret < 16)
+ if (ret < 0)
return ret;
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);