diff mbox

[FFmpeg-devel,ogg] Respect AVERROR codes returned by ogg header parsing.

Message ID CAPUDrwejTJHqVuE68p5tjt5p1A=NXgKT302an1ASEbNhnhRh8g@mail.gmail.com
State Superseded
Headers show

Commit Message

Dale Curtis Nov. 30, 2017, 8:19 p.m. UTC
On Wed, Nov 29, 2017 at 5:58 PM, Michael Niedermayer <michael@niedermayer.cc
> wrote:

>
> AV_EF_EXPLODE appears to be a possibility, yes
> in general demuxers should try to extract as much as possible from a
> file and not give up if some broken packet is found
>

I don't think this is a good idea; some of these errors seem fairly fatal
to the overall process. I think instead it's better to write off the sample
you have as being invalid. That said, I defer to your judgement here, so
I've produced both versions of the patch and leave it to your decision.
Chrome is now always using AV_EF_EXPLODE, so either works for our usage.

- dale

Comments

Michael Niedermayer Dec. 1, 2017, 1:49 a.m. UTC | #1
On Thu, Nov 30, 2017 at 12:19:10PM -0800, Dale Curtis wrote:
> On Wed, Nov 29, 2017 at 5:58 PM, Michael Niedermayer <michael@niedermayer.cc
> > wrote:
> 
> >
> > AV_EF_EXPLODE appears to be a possibility, yes
> > in general demuxers should try to extract as much as possible from a
> > file and not give up if some broken packet is found
> >
> 
> I don't think this is a good idea; some of these errors seem fairly fatal
> to the overall process. I think instead it's better to write off the sample
> you have as being invalid. That said, I defer to your judgement here, so
> I've produced both versions of the patch and leave it to your decision.
> Chrome is now always using AV_EF_EXPLODE, so either works for our usage.

Ive taken a deeper look as this doesnt sound right

I dont see anything really wrong with the file

it seems what happens is that theres a data packet in one stream that
preceeds the headers on the other streams, technically that data packet
likely contains the video headers so its kind of a header too.

The demuxer stops header parsing prematurly due to this.
from there on it gets confused reading the same header twice
while it determines the duration of the file which triggers the error

There are a few differnt ways to fix this, iam not sure which is the
simplest but i dont think the demuxer should fail in this case

[...]
diff mbox

Patch

From 80975de4c72f81d65ad9d3fa0c45ea2903a52434 Mon Sep 17 00:00:00 2001
From: Dale Curtis <dalecurtis@chromium.org>
Date: Tue, 28 Nov 2017 13:40:20 -0800
Subject: [PATCH] Respect AVERROR codes returned by ogg parsers.

Fixes ticket #6804. All of the ogg header and packet parsers may
return standard AVERROR codes; these return values should not be
treated as success.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
---
 libavformat/oggdec.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 193a286e43..a55743db0d 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -543,7 +543,11 @@  static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
     os->incomplete = 0;
 
     if (os->header) {
-        os->header = os->codec->header(s, idx);
+        if ((ret = os->codec->header(s, idx)) < 0) {
+            av_log(s, AV_LOG_ERROR, "Header processing failed: %d\n", ret);
+            return ret;
+        }
+        os->header = ret;
         if (!os->header) {
             os->segp  = segp;
             os->psize = psize;
@@ -574,8 +578,12 @@  static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
     } else {
         os->pflags    = 0;
         os->pduration = 0;
-        if (os->codec && os->codec->packet)
-            os->codec->packet(s, idx);
+        if (os->codec && os->codec->packet) {
+            if ((ret = os->codec->packet(s, idx)) < 0) {
+                av_log(s, AV_LOG_ERROR, "Packet processing failed: %d\n", ret);
+                return ret;
+            }
+        }
         if (sid)
             *sid = idx;
         if (dstart)
-- 
2.15.0.531.g2ccb3012c9-goog