History

avformat/mov: check that child boxes of trak are only present inside it

Based on the check done for the stco box.

James Almer committed 2 years ago

Commit e7d3ff81 parent 2aa63781 file · +30 −0Browse files

Unified · Split

libavformat/mov.c+30−0
@@ -3145,6 +3145,11 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 3144 unmodified lines
31453145 MOVStreamContext *sc;
31463146 unsigned int i, entries;
31473147
3148+ if (c->trak_index < 0) {
3149+ av_log(c->fc, AV_LOG_WARNING, "STSC outside TRAK\n");
3150+ return 0;
3151+ }
3152+
31483153 if (c->fc->nb_streams < 1)
31493154 return 0;
31503155 st = c->fc->streams[c->fc->nb_streams-1];
@@ -3241,6 +3246,11 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 90 unmodified lines
32413246 MOVStreamContext *sc;
32423247 unsigned i, entries;
32433248
3249+ if (c->trak_index < 0) {
3250+ av_log(c->fc, AV_LOG_WARNING, "STPS outside TRAK\n");
3251+ return 0;
3252+ }
3253+
32443254 if (c->fc->nb_streams < 1)
32453255 return 0;
32463256 st = c->fc->streams[c->fc->nb_streams-1];
@@ -3278,6 +3288,11 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 31 unmodified lines
32783288 MOVStreamContext *sc;
32793289 unsigned int i, entries;
32803290
3291+ if (c->trak_index < 0) {
3292+ av_log(c->fc, AV_LOG_WARNING, "STSS outside TRAK\n");
3293+ return 0;
3294+ }
3295+
32813296 if (c->fc->nb_streams < 1)
32823297 return 0;
32833298 st = c->fc->streams[c->fc->nb_streams-1];
@@ -3330,6 +3345,11 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 46 unmodified lines
33303345 unsigned char* buf;
33313346 int ret;
33323347
3348+ if (c->trak_index < 0) {
3349+ av_log(c->fc, AV_LOG_WARNING, "STSZ outside TRAK\n");
3350+ return 0;
3351+ }
3352+
33333353 if (c->fc->nb_streams < 1)
33343354 return 0;
33353355 st = c->fc->streams[c->fc->nb_streams-1];
@@ -3419,6 +3439,11 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 83 unmodified lines
34193439 int64_t current_dts = 0;
34203440 int64_t corrected_dts = 0;
34213441
3442+ if (c->trak_index < 0) {
3443+ av_log(c->fc, AV_LOG_WARNING, "STTS outside TRAK\n");
3444+ return 0;
3445+ }
3446+
34223447 if (c->fc->nb_streams < 1)
34233448 return 0;
34243449 st = c->fc->streams[c->fc->nb_streams-1];
@@ -3575,6 +3600,11 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 150 unmodified lines
35753600 MOVStreamContext *sc;
35763601 unsigned int i, entries, ctts_count = 0;
35773602
3603+ if (c->trak_index < 0) {
3604+ av_log(c->fc, AV_LOG_WARNING, "CTTS outside TRAK\n");
3605+ return 0;
3606+ }
3607+
35783608 if (c->fc->nb_streams < 1)
35793609 return 0;
35803610 st = c->fc->streams[c->fc->nb_streams-1];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t