[MPlayer-cvslog] r34914 - trunk/libmpdemux/demux_audio.c

reimar subversion at mplayerhq.hu
Fri May 18 19:01:14 CEST 2012


Author: reimar
Date: Fri May 18 19:01:13 2012
New Revision: 34914

Log:
Add some additional checks to ensure subtractions do not overflow.

Patch by Benoît Thébaudeau [benoit thebaudeau advansee com].

Modified:
   trunk/libmpdemux/demux_audio.c

Modified: trunk/libmpdemux/demux_audio.c
==============================================================================
--- trunk/libmpdemux/demux_audio.c	Fri May 18 00:10:19 2012	(r34913)
+++ trunk/libmpdemux/demux_audio.c	Fri May 18 19:01:13 2012	(r34914)
@@ -440,13 +440,14 @@ static int demux_audio_open(demuxer_t* d
     duration = (double) mp3_vbr_frames(s, demuxer->movi_start) * mp3_found->mpa_spf / mp3_found->mp3_freq;
     free(mp3_found);
     mp3_found = NULL;
-    if(s->end_pos && (s->flags & MP_STREAM_SEEK) == MP_STREAM_SEEK) {
-      stream_seek(s,s->end_pos-128);
+    if(demuxer->movi_end && (s->flags & MP_STREAM_SEEK) == MP_STREAM_SEEK) {
+      if(demuxer->movi_end >= 128) {
+        stream_seek(s,demuxer->movi_end-128);
       stream_read(s,hdr,3);
       if(!memcmp(hdr,"TAG",3)) {
 	char buf[31];
 	uint8_t g;
-	demuxer->movi_end = stream_tell(s)-3;
+          demuxer->movi_end -= 128;
 	stream_read(s,buf,30);
 	buf[30] = '\0';
 	demux_info_add(demuxer,"Title",buf);
@@ -470,6 +471,8 @@ static int demux_audio_open(demuxer_t* d
 	g = stream_read_char(s);
 	demux_info_add(demuxer,"Genre",genres[g]);
       }
+      }
+      if(demuxer->movi_end >= 10) {
       stream_seek(s,demuxer->movi_end-10);
       stream_read(s,hdr,4);
       if(!memcmp(hdr,"3DI",3) && hdr[3] >= 4 && hdr[3] != 0xff) {
@@ -490,6 +493,7 @@ static int demux_audio_open(demuxer_t* d
         }
       }
     }
+    }
     if (duration && demuxer->movi_end && demuxer->movi_end > demuxer->movi_start) sh_audio->wf->nAvgBytesPerSec = (demuxer->movi_end - demuxer->movi_start) / duration;
     sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec;
     break;


More information about the MPlayer-cvslog mailing list