mkvmuxer: Reject frames if invalid track number is passed.

Reject frames if an invalid track number is passed. Also change sample_muxer
to reject files which have Block elements with invalid track numbers.

Fixes Issue #659: https://code.google.com/p/webm/issues/detail?id=659

Change-Id: Ie6cf39a409b68bb4d2261f308409ee0c36d5dd8e
This commit is contained in:
Vignesh Venkatasubramanian 2014-05-16 13:42:13 -07:00
parent 249629d46c
commit 07688c92d7
2 changed files with 27 additions and 0 deletions

View File

@ -2276,6 +2276,10 @@ bool Segment::AddFrame(const uint8* frame, uint64 length, uint64 track_number,
if (timestamp < last_timestamp_)
return false;
// Check if the track number is valid.
if (!tracks_.GetTrackByNumber(track_number))
return false;
// If the segment has a video track hold onto audio frames to make sure the
// audio that is associated with the start time of a video key-frame is
// muxed into the same cluster.
@ -2335,6 +2339,10 @@ bool Segment::AddFrameWithAdditional(const uint8* frame, uint64 length,
if (timestamp < last_timestamp_)
return false;
// Check if the track number is valid.
if (!tracks_.GetTrackByNumber(track_number))
return false;
// If the segment has a video track hold onto audio frames to make sure the
// audio that is associated with the start time of a video key-frame is
// muxed into the same cluster.
@ -2395,6 +2403,10 @@ bool Segment::AddFrameWithDiscardPadding(const uint8* frame, uint64 length,
if (timestamp < last_timestamp_)
return false;
// Check if the track_number is valid.
if (!tracks_.GetTrackByNumber(track_number))
return false;
// If the segment has a video track hold onto audio frames to make sure the
// audio that is associated with the start time of a video key-frame is
// muxed into the same cluster.
@ -2455,6 +2467,10 @@ bool Segment::AddMetadata(const uint8* frame, uint64 length,
if (timestamp_ns < last_timestamp_)
return false;
// Check if the track number is valid.
if (!tracks_.GetTrackByNumber(track_number))
return false;
if (!DoNewClusterProcessing(track_number, timestamp_ns, true))
return false;
@ -2481,6 +2497,9 @@ bool Segment::AddMetadata(const uint8* frame, uint64 length,
}
bool Segment::AddGenericFrame(const Frame* frame) {
if (!tracks_.GetTrackByNumber(frame->track_number())) {
return false;
}
last_block_duration_ = frame->duration();
if (!tracks_.TrackIsAudio(frame->track_number()) &&
!tracks_.TrackIsVideo(frame->track_number()) && frame->duration() > 0) {

View File

@ -457,6 +457,14 @@ int main(int argc, char* argv[]) {
const long long trackNum = block->GetTrackNumber();
const mkvparser::Track* const parser_track =
parser_tracks->GetTrackByNumber(static_cast<unsigned long>(trackNum));
// When |parser_track| is NULL, it means that the track number in the
// Block is invalid (i.e.) the was no TrackEntry corresponding to the
// track number. So we reject the file.
if (!parser_track) {
return EXIT_FAILURE;
}
const long long track_type = parser_track->GetType();
const long long time_ns = block->GetTime(cluster);