Hi

Mplex crashes with divide-by-zero on invalid mp3 files. This is the patch.

Mikulas
diff -u -r MJPEGTOOLS-1.6.2-BAK/MPLEX/MPASTRM_IN.CPP 
MJPEGTOOLS-1.6.2/MPLEX/MPASTRM_IN.CPP
--- MJPEGTOOLS-1.6.2-BAK/MPLEX/MPASTRM_IN.CPP   2005-04-22 21:31:28.000000000 
+0200
+++ MJPEGTOOLS-1.6.2/MPLEX/MPASTRM_IN.CPP       2006-05-04 01:55:03.000000000 
+0200
@@ -145,18 +145,23 @@
                original_copy   = bs.Get1Bit ();
                emphasis                = bs.GetBits( 2);
 
+               samples_per_second = mpa_freq_table[version_id][frequency];
+               if (!samples_per_second) {
+                       mjpeg_error ( "Invalid frequency in MPEG Audio stream 
header.");
+                       exit (1);
+               }
+
                framesize =
                        mpa_bitrates_kbps[version_id][layer][bit_rate_code]  * 
                        mpa_slots[layer] *1000 /
-                       mpa_freq_table[version_id][frequency];
+                       samples_per_second;
 
                size_frames[0] = framesize;
                size_frames[1] = framesize+( layer == 0 ? 4 : 1);
                num_frames[padding_bit]++;
-        access_unit.start  = AU_start;
+               access_unit.start  = AU_start;
                access_unit.length = size_frames[padding_bit];
          
-               samples_per_second = mpa_freq_table[version_id][frequency];
 
                /* Presentation time-stamping  */
                access_unit.PTS = static_cast<clockticks>(decoding_order) * 

Reply via email to