[FFmpeg-devel] [PATCH 01/11] libavformat/mxfdec.c: klv_read_packet: Properly check klv_decode_ber_length return value.
Alexis Ballier
aballier at gentoo.org
Wed Oct 21 18:00:55 CEST 2015
klv_decode_ber_length cannot return -1, but can return AVERROR_INVALIDDATA.
Store its return value in a signed integer (instead of unsigned KLVPacket.length) and forward the error appropriately.
---
libavformat/mxfdec.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 00d420b..94a953b 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -366,13 +366,15 @@ static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size)
static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
{
+ int64_t len;
if (!mxf_read_sync(pb, mxf_klv_key, 4))
return AVERROR_INVALIDDATA;
klv->offset = avio_tell(pb) - 4;
memcpy(klv->key, mxf_klv_key, 4);
avio_read(pb, klv->key + 4, 12);
- klv->length = klv_decode_ber_length(pb);
- return klv->length == -1 ? -1 : 0;
+ len = klv_decode_ber_length(pb);
+ klv->length = FFMAX(len, 0);
+ return FFMIN(len, 0);
}
static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
--
2.6.2
More information about the ffmpeg-devel
mailing list