Skip to content

Commit 4fc9463

Browse files
authored
Merge pull request #51 from TechSmith/fixCrashInMP4GetTrackMediaDataName
Fix crash in mp4 get track media data name
2 parents 4a3dc06 + 71e1306 commit 4fc9463

7 files changed

Lines changed: 251 additions & 5 deletions

File tree

mp4v2-Win/include/mp4v2/project.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
#define MP4V2_PROJECT_name "MP4v2"
77
#define MP4V2_PROJECT_name_lower "mp4v2"
88
#define MP4V2_PROJECT_name_upper "MP4V2"
9-
#define MP4V2_PROJECT_name_formal "MP4v2 4.1.5.0"
9+
#define MP4V2_PROJECT_name_formal "MP4v2 4.1.6.0"
1010
#define MP4V2_PROJECT_url_website "http://code.google.com/p/mp4v2"
1111
#define MP4V2_PROJECT_url_downloads "http://code.google.com/p/mp4v2/downloads/list"
1212
#define MP4V2_PROJECT_url_discussion "http://groups.google.com/group/mp4v2"
1313
#define MP4V2_PROJECT_irc "irc://irc.freenode.net/handbrake"
1414
#define MP4V2_PROJECT_bugreport "<eddyg@myreflection.org>"
15-
#define MP4V2_PROJECT_version "4.1.5.0"
15+
#define MP4V2_PROJECT_version "4.1.6.0"
1616
#define MP4V2_PROJECT_version_hex 0x00020100
1717
#define MP4V2_PROJECT_version_major 4
1818
#define MP4V2_PROJECT_version_minor 1
19-
#define MP4V2_PROJECT_version_point 5
19+
#define MP4V2_PROJECT_version_point 6
2020
#define MP4V2_PROJECT_repo_url "https://mp4v2.googlecode.com/svn/trunk"
2121
#define MP4V2_PROJECT_repo_root "https://mp4v2.googlecode.com/svn"
2222
#define MP4V2_PROJECT_repo_uuid "6e6572fa-98a6-11dd-ad9f-f77439c74b79"

mp4v2-Win/mp4v2.autopkg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ nuget
1010
nuspec
1111
{
1212
id = mp4v2;
13-
version: 4.1.5;
13+
version: 4.1.6;
1414
title: MP4v2 Library;
1515
authors: { TechSmith Corporation };
1616
owners: { TechSmith Corporation };
@@ -35,7 +35,8 @@ nuget
3535
4.1.2 Finalize changes to handle ProRes MOV files correctly
3636
4.1.3 ftyp atom optional for MOV files
3737
4.1.4 Update to VS 2019; allow parsing of some atoms to be skipped
38-
4.1.5 Revert to VS 2017";
38+
4.1.5 Revert to VS 2017
39+
4.1.6 Fix crash with fuzzed mp4";
3940
copyright: "";
4041
tags: { native, mp4v2, mp4, vs2017 };
4142
};

mp4v2-Win/mp4v2.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
..\README = ..\README
1313
EndProjectSection
1414
EndProject
15+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "runner\runner.vcxproj", "{5A3D5BCC-6781-4A0D-AB87-82C410569A23}"
16+
EndProject
1517
Global
1618
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1719
Debug|Win32 = Debug|Win32
@@ -28,6 +30,14 @@ Global
2830
{BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|Win32.Build.0 = Release|Win32
2931
{BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|x64.ActiveCfg = Release|x64
3032
{BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|x64.Build.0 = Release|x64
33+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|Win32.ActiveCfg = Debug|Win32
34+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|Win32.Build.0 = Debug|Win32
35+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|x64.ActiveCfg = Debug|x64
36+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Debug|x64.Build.0 = Debug|x64
37+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|Win32.ActiveCfg = Release|Win32
38+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|Win32.Build.0 = Release|Win32
39+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|x64.ActiveCfg = Release|x64
40+
{5A3D5BCC-6781-4A0D-AB87-82C410569A23}.Release|x64.Build.0 = Release|x64
3141
EndGlobalSection
3242
GlobalSection(SolutionProperties) = preSolution
3343
HideSolutionNode = FALSE

mp4v2-Win/runner/runner.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// runner.cpp : This file contains the 'main' function. Program execution begins and ends there.
2+
#include <iostream>
3+
#include <mp4v2/mp4v2.h>
4+
5+
#include <vector>
6+
7+
namespace
8+
{
9+
bool parseAtomCallback( uint32_t fourCC )
10+
{
11+
static const std::vector<uint32_t> atomsToSkip = { 'udta', 'text' };
12+
13+
return std::find( atomsToSkip.cbegin(), atomsToSkip.cend(), fourCC ) == atomsToSkip.cend();
14+
}
15+
16+
bool isVideoTrack( MP4FileHandle fh, MP4TrackId trackId )
17+
{
18+
return strcmp( ::MP4GetTrackType( fh, trackId ), MP4_VIDEO_TRACK_TYPE ) == 0;
19+
}
20+
}
21+
22+
std::vector<MP4TrackId> mp4TrackIdsOfAllVideoTracks( MP4FileHandle handle )
23+
{
24+
std::vector<MP4TrackId> trackIds;
25+
uint32_t numTracks = ::MP4GetNumberOfTracks( handle );
26+
for ( uint32_t trackIndex = 0; trackIndex < numTracks; ++trackIndex )
27+
{
28+
MP4TrackId trackId = ::MP4FindTrackId( handle, (uint16_t)trackIndex );
29+
if ( isVideoTrack( handle, trackId ) )
30+
trackIds.push_back( trackId );
31+
}
32+
return trackIds;
33+
}
34+
35+
int main()
36+
{
37+
std::string path = "C:\\Users\\d.cheng.TSCCORP\\Desktop\\bugs\\2856 - Crash importing fuzzed MP4\\fuzzed.mp4";
38+
MP4FileHandle fh = MP4Read( path.c_str(), parseAtomCallback );
39+
40+
std::vector<MP4TrackId> videoTrackIds = mp4TrackIdsOfAllVideoTracks( fh );
41+
for ( MP4TrackId videoTrackId : videoTrackIds )
42+
{
43+
const char * pFourccStr = ::MP4GetTrackMediaDataName( fh, videoTrackId );
44+
if ( pFourccStr == nullptr || strlen( pFourccStr ) != 4 )
45+
return false; // invalid fourCC, track can't be supported
46+
}
47+
return true;
48+
49+
MP4Close( fh );
50+
}

mp4v2-Win/runner/runner.vcxproj

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{5a3d5bcc-6781-4a0d-ab87-82c410569a23}</ProjectGuid>
25+
<RootNamespace>runner</RootNamespace>
26+
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v141</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v141</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v141</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v141</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<LinkIncremental>true</LinkIncremental>
75+
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
78+
<LinkIncremental>false</LinkIncremental>
79+
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
82+
<LinkIncremental>true</LinkIncremental>
83+
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
84+
</PropertyGroup>
85+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
86+
<LinkIncremental>false</LinkIncremental>
87+
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
88+
</PropertyGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
90+
<ClCompile>
91+
<WarningLevel>Level3</WarningLevel>
92+
<SDLCheck>true</SDLCheck>
93+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
94+
<ConformanceMode>true</ConformanceMode>
95+
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
96+
</ClCompile>
97+
<Link>
98+
<SubSystem>Console</SubSystem>
99+
<GenerateDebugInformation>true</GenerateDebugInformation>
100+
</Link>
101+
</ItemDefinitionGroup>
102+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
103+
<ClCompile>
104+
<WarningLevel>Level3</WarningLevel>
105+
<FunctionLevelLinking>true</FunctionLevelLinking>
106+
<IntrinsicFunctions>true</IntrinsicFunctions>
107+
<SDLCheck>true</SDLCheck>
108+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
109+
<ConformanceMode>true</ConformanceMode>
110+
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
111+
</ClCompile>
112+
<Link>
113+
<SubSystem>Console</SubSystem>
114+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
115+
<OptimizeReferences>true</OptimizeReferences>
116+
<GenerateDebugInformation>true</GenerateDebugInformation>
117+
</Link>
118+
</ItemDefinitionGroup>
119+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
120+
<ClCompile>
121+
<WarningLevel>Level3</WarningLevel>
122+
<SDLCheck>true</SDLCheck>
123+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
124+
<ConformanceMode>true</ConformanceMode>
125+
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
126+
</ClCompile>
127+
<Link>
128+
<SubSystem>Console</SubSystem>
129+
<GenerateDebugInformation>true</GenerateDebugInformation>
130+
</Link>
131+
</ItemDefinitionGroup>
132+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
133+
<ClCompile>
134+
<WarningLevel>Level3</WarningLevel>
135+
<FunctionLevelLinking>true</FunctionLevelLinking>
136+
<IntrinsicFunctions>true</IntrinsicFunctions>
137+
<SDLCheck>true</SDLCheck>
138+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
139+
<ConformanceMode>true</ConformanceMode>
140+
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
141+
</ClCompile>
142+
<Link>
143+
<SubSystem>Console</SubSystem>
144+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
145+
<OptimizeReferences>true</OptimizeReferences>
146+
<GenerateDebugInformation>true</GenerateDebugInformation>
147+
</Link>
148+
</ItemDefinitionGroup>
149+
<ItemGroup>
150+
<ClCompile Include="runner.cpp" />
151+
</ItemGroup>
152+
<ItemGroup>
153+
<ProjectReference Include="..\libmp4v2\libmp4v2.vcxproj">
154+
<Project>{bdb97a37-90b8-4906-bcab-663d983e33e3}</Project>
155+
</ProjectReference>
156+
</ItemGroup>
157+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
158+
<ImportGroup Label="ExtensionTargets">
159+
</ImportGroup>
160+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="runner.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>

src/mp4file.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3461,6 +3461,9 @@ const char *MP4File::GetTrackMediaDataName (MP4TrackId trackId)
34613461
MP4Atom *pAtom =
34623462
FindAtom(MakeTrackName(trackId,
34633463
"mdia.minf.stbl.stsd"));
3464+
if ( pAtom == nullptr )
3465+
return nullptr;
3466+
34643467
if (pAtom->GetNumberOfChildAtoms() != 1) {
34653468
log.errorf("%s: \"%s\": track %d has more than 1 child atoms in stsd",
34663469
__FUNCTION__, GetFilename().c_str(), trackId);

0 commit comments

Comments
 (0)