[FFmpeg-devel] [PATCH 01/11] libavformat/mxfdec.c: klv_read_packet: Properly check klv_decode_ber_length return value.
Tomas Härdin
tomas.hardin at codemill.se
Wed Oct 21 23:31:29 CEST 2015
On Wed, 2015-10-21 at 18:00 +0200, Alexis Ballier wrote:
> 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);
> }
Can't klv_read_packet() return int64_t instead?
/Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151021/3942783e/attachment.sig>
More information about the ffmpeg-devel
mailing list