History

mkv: Validate ASS Start and End fields

Luca Barbato committed 12 years ago

Commit 69c1fe71 parent 7834a541 file · +19 −2Browse files

Unified · Split

libavformat/matroskaenc.c+19−2
@@ -1227,7 +1227,7 @@ static int mkv_blockgroup_size(int pkt_size) · 1226 unmodified lines
12271227 return size;
12281228 }
12291229
1230−static int ass_get_duration(const uint8_t *p)
1230+static int ass_get_duration(AVFormatContext *s, const uint8_t *p)
12311231 {
12321232 int sh, sm, ss, sc, eh, em, es, ec;
12331233 uint64_t start, end;
@@ -1235,8 +1235,25 @@ static int ass_get_duration(const uint8_t *p) · 1 unmodified line
12351235 if (sscanf(p, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",
12361236 &sh, &sm, &ss, &sc, &eh, &em, &es, &ec) != 8)
12371237 return 0;
1238+
1239+ if (sh > 9 || sm > 59 || ss > 59 || sc > 99 ||
1240+ eh > 9 || em > 59 || es > 59 || ec > 99) {
1241+ av_log(s, AV_LOG_WARNING,
1242+ "Non-standard time reference %d:%d:%d.%d,%d:%d:%d.%d\n",
1243+ sh, sm, ss, sc, eh, em, es, ec);
1244+ return 0;
1245+ }
1246+
12381247 start = 3600000 * sh + 60000 * sm + 1000 * ss + 10 * sc;
12391248 end = 3600000 * eh + 60000 * em + 1000 * es + 10 * ec;
1249+
1250+ if (start > end) {
1251+ av_log(s, AV_LOG_WARNING,
1252+ "Unexpected time reference %d:%d:%d.%d,%d:%d:%d.%d\n",
1253+ sh, sm, ss, sc, eh, em, es, ec);
1254+ return 0;
1255+ }
1256+
12401257 return end - start;
12411258 }
12421259
@@ -1250,7 +1267,7 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, · 7 unmodified lines
12501267 char buffer[2048];
12511268
12521269 while (data_size) {
1253− int duration = ass_get_duration(data);
1270+ int duration = ass_get_duration(s, data);
12541271 max_duration = FFMAX(duration, max_duration);
12551272 end = memchr(data, '\n', data_size);
12561273 size = line_size = end ? end - data + 1 : data_size;

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