Skip to content

Commit e228196

Browse files
authored
Merge pull request #76 from TechSmith/mp4v2_security_fixes
mp4v2 security fixes
2 parents 339f1da + 01a8cd2 commit e228196

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

src/atom_ftyp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ void MP4FtypAtom::Generate()
5353

5454
void MP4FtypAtom::Read()
5555
{
56+
if ( m_size == 0ULL )
57+
return;
58+
5659
compatibleBrands.SetCount( (m_size - 8) / 4 ); // brands array fills rest of atom
5760
MP4Atom::Read();
5861
}

src/atoms.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,9 @@ class MP4SdtpAtom : public MP4FullAtom {
491491
// number of bytes == stsz.sampleCount.
492492
MP4BytesProperty& data;
493493
private:
494-
MP4SdtpAtom();
495-
MP4SdtpAtom( const MP4SdtpAtom &src );
496-
MP4SdtpAtom &operator= ( const MP4SdtpAtom &src );
494+
MP4SdtpAtom() = delete;
495+
MP4SdtpAtom( const MP4SdtpAtom& src ) = delete;
496+
MP4SdtpAtom& operator=( const MP4SdtpAtom& src ) = delete;
497497
};
498498

499499
class MP4SmiAtom : public MP4Atom {

src/mp4atom.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,15 @@ void MP4Atom::ReadProperties(uint32_t startIndex, uint32_t count)
395395
m_File.GetPosition(), m_end);
396396

397397
ostringstream oss;
398-
oss << "atom '" << GetType() << "' is too small; overrun at property: " << m_pProperties[i]->GetName();
398+
const char* propName = nullptr;
399+
auto prop = m_pProperties[i];
400+
if ( prop != nullptr )
401+
propName = prop->GetName();
402+
if ( propName != nullptr )
403+
oss << "atom '" << GetType() << "' is too small; overrun at property: " << propName;
404+
else
405+
oss << "atom '" << GetType() << "' is too small; overrun reading property";
406+
399407
throw new Exception( oss.str().c_str(), __FILE__, __LINE__, __FUNCTION__ );
400408
}
401409

src/mp4track.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,15 @@ MP4Track::MP4Track(MP4File& file, MP4Atom& trakAtom)
237237
CalculateBytesPerSample();
238238

239239
// update sdtp log from sdtp atom
240-
MP4SdtpAtom* sdtp = (MP4SdtpAtom*)m_trakAtom.FindAtom( "trak.mdia.minf.stbl.sdtp" );
241-
if( sdtp ) {
242-
uint8_t* buffer;
243-
uint32_t bufsize;
244-
sdtp->data.GetValue( &buffer, &bufsize );
245-
m_sdtpLog.assign( (char*)buffer, bufsize );
246-
free( buffer );
240+
MP4Atom* atom = m_trakAtom.FindAtom( "trak.mdia.minf.stbl.sdtp" );
241+
MP4SdtpAtom* sdtp = dynamic_cast<MP4SdtpAtom *>( atom );
242+
if ( sdtp != nullptr )
243+
{
244+
uint8_t* buffer;
245+
uint32_t bufsize;
246+
sdtp->data.GetValue( &buffer, &bufsize );
247+
m_sdtpLog.assign( (char*)buffer, bufsize );
248+
free( buffer );
247249
}
248250
}
249251

0 commit comments

Comments
 (0)