[FFmpeg-devel] [PATCH 3/3] lavf/movdec: don't treat I/O errors as EOF

Rodger Combs rodger.combs at gmail.com
Wed Nov 28 09:19:59 EET 2018


---
 libavformat/mov.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 542e92ec00..607ce30178 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -645,7 +645,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
             for (type = 0; type != -1 && avio_tell(pb) < next; ) {
                 if(avio_feof(pb))
-                    return AVERROR_EOF;
+                    return pb->error ? pb->error : AVERROR_EOF;
                 type = avio_rb16(pb);
                 len = avio_rb16(pb);
                 av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
@@ -2001,9 +2001,9 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     sc->chunk_count = i;
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STCO atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     return 0;
@@ -2535,9 +2535,9 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
         sc->stsd_count++;
     }
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSD atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     return 0;
@@ -2669,9 +2669,9 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
     }
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSC atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     return 0;
@@ -2723,9 +2723,9 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     sc->stps_count = i;
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STPS atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     return 0;
@@ -2772,9 +2772,9 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     sc->keyframe_count = i;
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSS atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     return 0;
@@ -2860,9 +2860,9 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     av_free(buf);
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSZ atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     return 0;
@@ -2938,9 +2938,9 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         sc->nb_frames_for_fps += total_sample_count;
     }
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STTS atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     st->nb_frames= total_sample_count;
@@ -3017,7 +3017,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     sc->ctts_count = ctts_count;
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted CTTS atom\n");
         return AVERROR_EOF;
     }
@@ -3066,9 +3066,9 @@ static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     sc->rap_group_count = i;
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted SBGP atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     return 0;
@@ -4912,9 +4912,9 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     fix_frag_index_entries(&c->frag_index, next_frag_index,
                            frag->track_id, entries);
 
-    if (pb->eof_reached) {
+    if (avio_feof(pb)) {
         av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted TRUN atom\n");
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     }
 
     frag->implicit_offset = offset;
@@ -7627,7 +7627,7 @@ static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
     if (ret < 0)
         return ret;
     if (avio_feof(s->pb))
-        return AVERROR_EOF;
+        return pb->error ? pb->error : AVERROR_EOF;
     av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb));
 
     return 1;
-- 
2.19.1



More information about the ffmpeg-devel mailing list