changeset 7910:5a276890cec4

check for framesize validity, return -1 (error) for zero size (bug found by pl)
author arpi
date Fri, 25 Oct 2002 14:33:51 +0000
parents 6f76eebc0318
children dd3f18c7b006
files libmpdemux/mp3_hdr.c
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/mp3_hdr.c	Fri Oct 25 14:13:32 2002 +0000
+++ b/libmpdemux/mp3_hdr.c	Fri Oct 25 14:33:51 2002 +0000
@@ -6,13 +6,13 @@
 //----------------------- mp3 audio frame header parser -----------------------
 
 static int tabsel_123[2][3][16] = {
-   { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
-     {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
-     {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
+   { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
+     {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,0},
+     {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,0} },
 
-   { {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
-     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
-     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
+   { {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,0},
+     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0},
+     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0} }
 };
 static long freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 };
 
@@ -96,7 +96,13 @@
       ssize = (stereo == 1) ? 17 : 32;
     if(crc) ssize += 2;
 
-    framesize  = (long) tabsel_123[lsf][2][bitrate_index] * 144000;
+    framesize = tabsel_123[lsf][2][bitrate_index] * 144000;
+
+    if(!framesize){
+	mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid framesize/bitrate_index\n");
+	return -1;  // valid: 1..14
+    }
+
     framesize /= freqs[sampling_frequency]<<lsf;
     framesize += padding;