changeset 20878:908aa826d8ed

Try to handle oversized asf headers by ignoring anything beyond the first MB
author reimar
date Mon, 13 Nov 2006 19:16:39 +0000
parents 80f8846c7df0
children 8c029c5b800a
files libmpdemux/asfheader.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/asfheader.c	Mon Nov 13 18:41:24 2006 +0000
+++ b/libmpdemux/asfheader.c	Mon Nov 13 19:16:39 2006 +0000
@@ -231,6 +231,7 @@
 
 int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
   int hdr_len = asf->header.objh.size - sizeof(asf->header);
+  int hdr_skip = 0;
   char *hdr = NULL;
   char guid_buffer[16];
   int pos, start = stream_tell(demuxer->stream);
@@ -251,9 +252,10 @@
   }
     
   if (hdr_len > 1024 * 1024) {
-    mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_HeaderSizeOver1MB,
+    mp_msg(MSGT_HEADER, MSGL_ERR, MSGTR_MPDEMUX_ASFHDR_HeaderSizeOver1MB,
 			hdr_len);
-    return 0;
+    hdr_skip = hdr_len - 1024 * 1024;
+    hdr_len = 1024 * 1024;
   }
   hdr = malloc(hdr_len);
   if (!hdr) {
@@ -262,6 +264,8 @@
     return 0;
   }
   stream_read(demuxer->stream, hdr, hdr_len);
+  if (hdr_skip)
+    stream_skip(demuxer->stream, hdr_skip);
   if (stream_eof(demuxer->stream)) {
     mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_EOFWhileReadingHeader);
     goto err_out;