diff mbox

[FFmpeg-devel] lavf/cafdec: Do not fail for unknown atoms with negative size.

Message ID CAB0OVGpcLBRhjAVn7Be=tWS_-ygxVgzstOFA2WLZzwGngdKTAw@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Jan. 26, 2019, 2:26 p.m. UTC
2019-01-25 17:49 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> On 1/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> Hi!
>>
>> Attached patch allows to read a user's file that plays fine with QT.
>> The patch duplicates the behaviour of QT.
>>
>> Please comment, Carl Eugen
>
> lgtm

Sorry, I had attached the wrong patch.

New patch attached, Carl Eugen

Comments

Paul B Mahol Jan. 26, 2019, 2:38 p.m. UTC | #1
On 1/26/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2019-01-25 17:49 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> On 1/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>> Hi!
>>>
>>> Attached patch allows to read a user's file that plays fine with QT.
>>> The patch duplicates the behaviour of QT.
>>>
>>> Please comment, Carl Eugen
>>
>> lgtm
>
> Sorry, I had attached the wrong patch.
>
> New patch attached, Carl Eugen
>

lgtm
Carl Eugen Hoyos Jan. 27, 2019, 1:35 p.m. UTC | #2
2019-01-26 15:38 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> On 1/26/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> 2019-01-25 17:49 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>>> On 1/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>> Hi!
>>>>
>>>> Attached patch allows to read a user's file that plays fine with QT.
>>>> The patch duplicates the behaviour of QT.
>>>>
>>>> Please comment, Carl Eugen
>>>
>>> lgtm
>>
>> Sorry, I had attached the wrong patch.
>>
>> New patch attached, Carl Eugen
>>
>
> lgtm

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

From 67d49072d60b95ffc8838a20cb87b33b5904dc21 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Tue, 15 Jan 2019 00:22:50 +0100
Subject: [PATCH] lavf/cafdec: Do not fail for unknown atoms with negative
 size.

The specification requires the demuxer to only read the data
atom up to its given size, this is necessary as atoms are
allowed at the end of the file.
This patch duplicates the behaviour of the QuickTime player.
---
 libavformat/cafdec.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 7652d9e..20956bc 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -310,6 +310,8 @@  static int read_header(AVFormatContext *s)
                    "skipping CAF chunk: %08"PRIX32" (%s), size %"PRId64"\n",
                    tag, av_fourcc2str(av_bswap32(tag)), size);
         case MKBETAG('f','r','e','e'):
+            if (size < 0 && found_data)
+                goto found_data;
             if (size < 0)
                 return AVERROR_INVALIDDATA;
             break;
@@ -325,6 +327,7 @@  static int read_header(AVFormatContext *s)
     if (!found_data)
         return AVERROR_INVALIDDATA;
 
+found_data:
     if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) {
         if (caf->data_size > 0)
             st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
-- 
1.7.10.4