From 52e478f2b662b8dc02ccecbd2d82501d8ffea508 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 5 Mar 2012 16:03:00 +0100 Subject: [PATCH] Ignore potential AC3 packets with invalid size fields Fix for bug 723. --- ChangeLog | 6 ++++++ src/common/ac3.cpp | 5 +++++ tests/results.txt | 1 + tests/test-347h264_misdetected_as_ac3.rb | 6 ++++++ 4 files changed, 18 insertions(+) create mode 100644 tests/test-347h264_misdetected_as_ac3.rb diff --git a/ChangeLog b/ChangeLog index f7ca9c892..07986b4f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-03-05 Moritz Bunkus + + * mkvmerge: bug fix: Sometimes non-AC3 files were mistakenly for + AC3 after the re-write of the AC3 handling code on + 2012-02-26. This has been rectified. Fix for bug 723. + 2012-03-04 Moritz Bunkus * mkvmerge: enhancement: mkvmerge will keep the "enabled" track diff --git a/src/common/ac3.cpp b/src/common/ac3.cpp index f61e758e1..9f23d7bb8 100644 --- a/src/common/ac3.cpp +++ b/src/common/ac3.cpp @@ -367,6 +367,11 @@ ac3::parser_c::find_consecutive_frames(unsigned char const *buffer, if (!current_frame.decode_header(&buffer[offset], buffer_size - offset)) break; + if (8 > current_frame.m_bytes) { + mxdebug_if(debug, boost::format("Current frame at %1% has invalid size %2%\n") % offset % current_frame.m_bytes); + break; + } + if ( (current_frame.m_bs_id != first_frame.m_bs_id) && (current_frame.m_channels != first_frame.m_channels) && (current_frame.m_sample_rate != first_frame.m_sample_rate)) { diff --git a/tests/results.txt b/tests/results.txt index c41c57045..69d78ff0c 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -191,3 +191,4 @@ T_342m2ts_interlaced_h264_from_arte:8c4d727aa228e4738c598e3ddc9d4571:passed:2012 T_343m2ts_interlaced_h264_match_of_the_day:fdab49f2f33981826793bb66aab97ca5:passed:20120304-171453:2.873804415 T_344microdvd_recognition:ok:passed:20120304-175209:0.082792556 T_345flag_enabled:efe07b85cd349a040ed79402256bd6ea-89e9b90881c73d55ac4eda07e20effe5:passed:20120304-181150:0.135757829 +T_347h264_misdetected_as_ac3:4dcd5541b962ce1d534e04481deadbec:passed:20120305-160017:2.617159557 diff --git a/tests/test-347h264_misdetected_as_ac3.rb b/tests/test-347h264_misdetected_as_ac3.rb new file mode 100644 index 000000000..837001c32 --- /dev/null +++ b/tests/test-347h264_misdetected_as_ac3.rb @@ -0,0 +1,6 @@ +#!/usr/bin/ruby -w + +# T_347h264_misdetected_as_ac3 +describe "mkvmerge / h264 misdetected as AC3, bug 723" + +test_identify "data/h264/misdetected-as-ac3-bug-723.h264"