From 48f0c8c9d2e08f5ee2d5e19a8c3ea70ccd7ff8aa Mon Sep 17 00:00:00 2001 From: David Cheng Date: Thu, 18 Mar 2021 09:52:36 -0400 Subject: [PATCH 1/6] Added a sln and a runner.vcxproj --- mp4v2-Win/mp4v2.sln | 14 ++- mp4v2-Win/runner/runner.cpp | 50 ++++++++ mp4v2-Win/runner/runner.vcxproj | 160 ++++++++++++++++++++++++ mp4v2-Win/runner/runner.vcxproj.filters | 22 ++++ 4 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 mp4v2-Win/runner/runner.cpp create mode 100644 mp4v2-Win/runner/runner.vcxproj create mode 100644 mp4v2-Win/runner/runner.vcxproj.filters diff --git a/mp4v2-Win/mp4v2.sln b/mp4v2-Win/mp4v2.sln index 39b1360..1135cab 100644 --- a/mp4v2-Win/mp4v2.sln +++ b/mp4v2-Win/mp4v2.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2042 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30621.155 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmp4v2", "libmp4v2\libmp4v2.vcxproj", "{BDB97A37-90B8-4906-BCAB-663D983E33E3}" EndProject @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\README = ..\README EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "runner\runner.vcxproj", "{5A3D5BCC-6781-4A0D-AB87-82C410569A23}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -28,6 +30,14 @@ Global {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|Win32.Build.0 = Release|Win32 {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|x64.ActiveCfg = Release|x64 {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|x64.Build.0 = Release|x64 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|Win32.ActiveCfg = Debug|Win32 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|Win32.Build.0 = Debug|Win32 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|x64.ActiveCfg = Debug|x64 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|x64.Build.0 = Debug|x64 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|Win32.ActiveCfg = Release|Win32 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|Win32.Build.0 = Release|Win32 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|x64.ActiveCfg = Release|x64 + {5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mp4v2-Win/runner/runner.cpp b/mp4v2-Win/runner/runner.cpp new file mode 100644 index 0000000..c692165 --- /dev/null +++ b/mp4v2-Win/runner/runner.cpp @@ -0,0 +1,50 @@ +// runner.cpp : This file contains the 'main' function. Program execution begins and ends there. +#include +#include + +#include + +namespace +{ + bool parseAtomCallback( uint32_t fourCC ) + { + static const std::vector atomsToSkip = { 'udta', 'text' }; + + return std::find( atomsToSkip.cbegin(), atomsToSkip.cend(), fourCC ) == atomsToSkip.cend(); + } + + bool isVideoTrack( MP4FileHandle fh, MP4TrackId trackId ) + { + return strcmp( ::MP4GetTrackType( fh, trackId ), MP4_VIDEO_TRACK_TYPE ) == 0; + } +} + +std::vector mp4TrackIdsOfAllVideoTracks( MP4FileHandle handle ) +{ + std::vector trackIds; + uint32_t numTracks = ::MP4GetNumberOfTracks( handle ); + for ( uint32_t trackIndex = 0; trackIndex < numTracks; ++trackIndex ) + { + MP4TrackId trackId = ::MP4FindTrackId( handle, (uint16_t)trackIndex ); + if ( isVideoTrack( handle, trackId ) ) + trackIds.push_back( trackId ); + } + return trackIds; +} + +int main() +{ + std::string path = "C:\\Users\\d.cheng.TSCCORP\\Desktop\\bugs\\2856 - Crash importing fuzzed MP4\\fuzzed.mp4"; + MP4FileHandle fh = MP4Read( path.c_str(), parseAtomCallback ); + + std::vector videoTrackIds = mp4TrackIdsOfAllVideoTracks( fh ); + for ( MP4TrackId videoTrackId : videoTrackIds ) + { + const char * pFourccStr = ::MP4GetTrackMediaDataName( fh, videoTrackId ); + if ( pFourccStr == nullptr || strlen( pFourccStr ) != 4 ) + return false; // invalid fourCC, track can't be supported + } + return true; + + MP4Close( fh ); +} diff --git a/mp4v2-Win/runner/runner.vcxproj b/mp4v2-Win/runner/runner.vcxproj new file mode 100644 index 0000000..011852f --- /dev/null +++ b/mp4v2-Win/runner/runner.vcxproj @@ -0,0 +1,160 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {5a3d5bcc-6781-4a0d-ab87-82c410569a23} + runner + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + + + + {bdb97a37-90b8-4906-bcab-663d983e33e3} + + + + + + \ No newline at end of file diff --git a/mp4v2-Win/runner/runner.vcxproj.filters b/mp4v2-Win/runner/runner.vcxproj.filters new file mode 100644 index 0000000..06fb13e --- /dev/null +++ b/mp4v2-Win/runner/runner.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file From aa06c07ec0b0e0e1b6dd82bf32821668059e8662 Mon Sep 17 00:00:00 2001 From: David Cheng Date: Thu, 18 Mar 2021 09:52:46 -0400 Subject: [PATCH 2/6] Fix crash when working with invalid file --- src/mp4file.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mp4file.cpp b/src/mp4file.cpp index cb5cc32..2160bd8 100644 --- a/src/mp4file.cpp +++ b/src/mp4file.cpp @@ -3461,6 +3461,9 @@ const char *MP4File::GetTrackMediaDataName (MP4TrackId trackId) MP4Atom *pAtom = FindAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd")); + if ( pAtom == nullptr ) + return nullptr; + if (pAtom->GetNumberOfChildAtoms() != 1) { log.errorf("%s: \"%s\": track %d has more than 1 child atoms in stsd", __FUNCTION__, GetFilename().c_str(), trackId); From c5f9f202d4ed1ee34b66e98932dbcbb2868dae11 Mon Sep 17 00:00:00 2001 From: David Cheng Date: Thu, 18 Mar 2021 10:05:13 -0400 Subject: [PATCH 3/6] Change sln back to VS2017 --- mp4v2-Win/mp4v2.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mp4v2-Win/mp4v2.sln b/mp4v2-Win/mp4v2.sln index 1135cab..c619b70 100644 --- a/mp4v2-Win/mp4v2.sln +++ b/mp4v2-Win/mp4v2.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30621.155 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2042 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmp4v2", "libmp4v2\libmp4v2.vcxproj", "{BDB97A37-90B8-4906-BCAB-663D983E33E3}" EndProject From 0a8e86d06a9241d2f9f738db532159a73007c352 Mon Sep 17 00:00:00 2001 From: David Cheng Date: Thu, 18 Mar 2021 10:29:02 -0400 Subject: [PATCH 4/6] Update autopkg --- mp4v2-Win/mp4v2.autopkg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mp4v2-Win/mp4v2.autopkg b/mp4v2-Win/mp4v2.autopkg index 7847d8f..17beea8 100644 --- a/mp4v2-Win/mp4v2.autopkg +++ b/mp4v2-Win/mp4v2.autopkg @@ -10,7 +10,7 @@ nuget nuspec { id = mp4v2; - version: 4.1.5; + version: 4.1.6; title: MP4v2 Library; authors: { TechSmith Corporation }; owners: { TechSmith Corporation }; @@ -35,7 +35,8 @@ nuget 4.1.2 Finalize changes to handle ProRes MOV files correctly 4.1.3 ftyp atom optional for MOV files 4.1.4 Update to VS 2019; allow parsing of some atoms to be skipped - 4.1.5 Revert to VS 2017"; + 4.1.5 Revert to VS 2017 + 4.1.6 Fix crash with fuzzed mp4"; copyright: ""; tags: { native, mp4v2, mp4, vs2017 }; }; From f7d1c20c8b0be4b20d82885f28572eb6e7c93f43 Mon Sep 17 00:00:00 2001 From: KMojek Date: Thu, 18 Mar 2021 10:39:53 -0400 Subject: [PATCH 5/6] Bump version number --- mp4v2-Win/include/mp4v2/project.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mp4v2-Win/include/mp4v2/project.h b/mp4v2-Win/include/mp4v2/project.h index 2d99c84..01d4acd 100644 --- a/mp4v2-Win/include/mp4v2/project.h +++ b/mp4v2-Win/include/mp4v2/project.h @@ -6,17 +6,17 @@ #define MP4V2_PROJECT_name "MP4v2" #define MP4V2_PROJECT_name_lower "mp4v2" #define MP4V2_PROJECT_name_upper "MP4V2" -#define MP4V2_PROJECT_name_formal "MP4v2 4.1.5.0" +#define MP4V2_PROJECT_name_formal "MP4v2 4.1.6.0" #define MP4V2_PROJECT_url_website "http://code.google.com/p/mp4v2" #define MP4V2_PROJECT_url_downloads "http://code.google.com/p/mp4v2/downloads/list" #define MP4V2_PROJECT_url_discussion "http://groups.google.com/group/mp4v2" #define MP4V2_PROJECT_irc "irc://irc.freenode.net/handbrake" #define MP4V2_PROJECT_bugreport "" -#define MP4V2_PROJECT_version "4.1.5.0" +#define MP4V2_PROJECT_version "4.1.6.0" #define MP4V2_PROJECT_version_hex 0x00020100 #define MP4V2_PROJECT_version_major 4 #define MP4V2_PROJECT_version_minor 1 -#define MP4V2_PROJECT_version_point 5 +#define MP4V2_PROJECT_version_point 6 #define MP4V2_PROJECT_repo_url "https://mp4v2.googlecode.com/svn/trunk" #define MP4V2_PROJECT_repo_root "https://mp4v2.googlecode.com/svn" #define MP4V2_PROJECT_repo_uuid "6e6572fa-98a6-11dd-ad9f-f77439c74b79" From 71e1306514c925bb17d6a0e89a3c8de6cb570897 Mon Sep 17 00:00:00 2001 From: KMojek Date: Thu, 18 Mar 2021 10:49:45 -0400 Subject: [PATCH 6/6] Another adjustment for VS 2017 --- mp4v2-Win/runner/runner.vcxproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mp4v2-Win/runner/runner.vcxproj b/mp4v2-Win/runner/runner.vcxproj index 011852f..aaced35 100644 --- a/mp4v2-Win/runner/runner.vcxproj +++ b/mp4v2-Win/runner/runner.vcxproj @@ -23,32 +23,32 @@ Win32Proj {5a3d5bcc-6781-4a0d-ab87-82c410569a23} runner - 10.0 + 8.1 Application true - v142 + v141 Unicode Application false - v142 + v141 true Unicode Application true - v142 + v141 Unicode Application false - v142 + v141 true Unicode