the object size is invalid in this case
---
 libavformat/asfdec.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 7146dcc..ad08649 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -166,10 +166,14 @@ static void swap_guid(ff_asf_guid guid)
     FFSWAP(unsigned char, guid[6], guid[7]);
 }
 
-static void align_position(AVIOContext *pb,  int64_t offset, uint64_t size)
+static void align_position(AVFormatContext *s,  int64_t offset, uint64_t size)
 {
-    if (avio_tell(pb) != offset + size)
-        avio_seek(pb, offset + size, SEEK_SET);
+    ASFContext *asf = s->priv_data;
+    AVIOContext *pb = s->pb;
+
+    if (!(asf->b_flags & ASF_FLAG_BROADCAST))
+        if (avio_tell(pb) != offset + size)
+            avio_seek(pb, offset + size, SEEK_SET);
 }
 
 static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g)
@@ -245,7 +249,7 @@ static int asf_read_marker(AVFormatContext *s, const 
GUIDParseTable *g)
         avpriv_new_chapter(s, i, (AVRational) { 1, 10000000 }, pts,
                            AV_NOPTS_VALUE, name);
     }
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
 
     return 0;
 }
@@ -507,7 +511,7 @@ static int asf_read_ext_content(AVFormatContext *s, const 
GUIDParseTable *g)
             return ret;
     }
 
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
     return 0;
 }
 
@@ -581,7 +585,7 @@ static int asf_read_metadata_obj(AVFormatContext *s, const 
GUIDParseTable *g)
         }
     }
 
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
     return 0;
 }
 
@@ -609,7 +613,7 @@ static int asf_read_content_desc(AVFormatContext *s, const 
GUIDParseTable *g)
         asf_read_metadata(s, titles[i], len[i], ch, buflen[i]);
         av_freep(&ch);
     }
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
 
     return 0;
 }
@@ -732,7 +736,7 @@ static int asf_read_stream_properties(AVFormatContext *s, 
const GUIDParseTable *
         if (stream_index == asf->asf_st[i]->stream_index) {
             av_log(s, AV_LOG_WARNING,
                    "Duplicate stream found, this stream will be ignored.\n");
-            align_position(pb, asf->offset, size);
+            align_position(s, asf->offset, size);
             return 0;
         }
 
@@ -784,7 +788,7 @@ static int asf_read_stream_properties(AVFormatContext *s, 
const GUIDParseTable *
     }
 
     asf->nb_streams++;
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
 
     return 0;
 }
@@ -855,7 +859,7 @@ static int asf_read_ext_stream_properties(AVFormatContext 
*s, const GUIDParseTab
     }
 
     if ((ret = ff_get_guid(pb, &guid)) < 0) {
-        align_position(pb, asf->offset, size);
+        align_position(s, asf->offset, size);
 
         return 0;
     }
@@ -866,7 +870,7 @@ static int asf_read_ext_stream_properties(AVFormatContext 
*s, const GUIDParseTab
             return ret;
     }
 
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
     return 0;
 }
 
@@ -891,7 +895,7 @@ static int asf_read_language_list(AVFormatContext *s, const 
GUIDParseTable *g)
         }
     }
 
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
     return 0;
 }
 
@@ -927,7 +931,7 @@ static int asf_read_data(AVFormatContext *s, const 
GUIDParseTable *g)
     avio_skip(pb, 2); // skip reserved field
     asf->first_packet_offset = avio_tell(pb);
     if (pb->seekable)
-        align_position(pb, asf->offset, asf->data_size);
+        align_position(s, asf->offset, asf->data_size);
 
     return 0;
 }
@@ -971,7 +975,7 @@ static int asf_read_simple_index(AVFormatContext *s, const 
GUIDParseTable *g)
         }
     }
     asf->is_simple_index = 1;
-    align_position(pb, asf->offset, size);
+    align_position(s, asf->offset, size);
 
     return 0;
 }
@@ -1628,6 +1632,7 @@ static int asf_read_header(AVFormatContext *s)
 
     asf->preroll         = 0;
     asf->is_simple_index = 0;
+    asf->b_flags         = 0;
     ff_get_guid(pb, &guid);
     if (ff_guidcmp(&guid, &ff_asf_header))
         return AVERROR_INVALIDDATA;
@@ -1658,7 +1663,7 @@ static int asf_read_header(AVFormatContext *s)
                 goto failed;
         } else {
             size = avio_rl64(pb);
-            align_position(pb, asf->offset, size);
+            align_position(s, asf->offset, size);
         }
         if (asf->data_reached && !pb->seekable)
             break;
-- 
2.0.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to