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
1227 return size;1227 return size;
1228}1228}
1229 1229
1230static int ass_get_duration(const uint8_t *p)1230static int ass_get_duration(AVFormatContext *s, const uint8_t *p)
1231{1231{
1232 int sh, sm, ss, sc, eh, em, es, ec;1232 int sh, sm, ss, sc, eh, em, es, ec;
1233 uint64_t start, end;1233 uint64_t start, end;
@@ -1235,8 +1235,25 @@ static int ass_get_duration(const uint8_t *p) · 1 unmodified line
1235 if (sscanf(p, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",1235 if (sscanf(p, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",
1236 &sh, &sm, &ss, &sc, &eh, &em, &es, &ec) != 8)1236 &sh, &sm, &ss, &sc, &eh, &em, &es, &ec) != 8)
1237 return 0;1237 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
1238 start = 3600000 * sh + 60000 * sm + 1000 * ss + 10 * sc;1247 start = 3600000 * sh + 60000 * sm + 1000 * ss + 10 * sc;
1239 end = 3600000 * eh + 60000 * em + 1000 * es + 10 * ec;1248 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
1240 return end - start;1257 return end - start;
1241}1258}
1242 1259
@@ -1250,7 +1267,7 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, · 7 unmodified lines
1250 char buffer[2048];1267 char buffer[2048];
1251 1268
1252 while (data_size) {1269 while (data_size) {
1253 int duration = ass_get_duration(data);1270 int duration = ass_get_duration(s, data);
1254 max_duration = FFMAX(duration, max_duration);1271 max_duration = FFMAX(duration, max_duration);
1255 end = memchr(data, '\n', data_size);1272 end = memchr(data, '\n', data_size);
1256 size = line_size = end ? end - data + 1 : data_size;1273 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