Mercurial > mplayer.hg
comparison sub/subreader.c @ 36189:71360817b772
Discard parts that we do not actually care about instead of
reading them in.
Since more than one character can match, this could read
beyond the target variable.
Based on patch by wm4 (nfxjfg googlemail.com).
author | reimar |
---|---|
date | Sat, 25 May 2013 12:06:55 +0000 |
parents | 389d43c448b3 |
children | 5c8339df2496 |
comparison
equal
deleted
inserted
replaced
36188:34116de1aa96 | 36189:71360817b772 |
---|---|
376 static subtitle *sub_ass_read_line_subviewer(stream_t *st, subtitle *current, int utf16) | 376 static subtitle *sub_ass_read_line_subviewer(stream_t *st, subtitle *current, int utf16) |
377 { | 377 { |
378 int h1, m1, s1, ms1, h2, m2, s2, ms2, j = 0; | 378 int h1, m1, s1, ms1, h2, m2, s2, ms2, j = 0; |
379 | 379 |
380 while (!current->text[0]) { | 380 while (!current->text[0]) { |
381 char line[LINE_LEN + 1], full_line[LINE_LEN + 1], sep; | 381 char line[LINE_LEN + 1], full_line[LINE_LEN + 1]; |
382 int i; | 382 int i; |
383 | 383 |
384 /* Parse SubRip header */ | 384 /* Parse SubRip header */ |
385 if (!stream_read_line(st, line, LINE_LEN, utf16)) | 385 if (!stream_read_line(st, line, LINE_LEN, utf16)) |
386 return NULL; | 386 return NULL; |
387 if (sscanf(line, "%d:%d:%d%[,.:]%d --> %d:%d:%d%[,.:]%d", | 387 if (sscanf(line, "%d:%d:%d%*[,.:]%d --> %d:%d:%d%*[,.:]%d", |
388 &h1, &m1, &s1, &sep, &ms1, &h2, &m2, &s2, &sep, &ms2) < 10) | 388 &h1, &m1, &s1, &ms1, &h2, &m2, &s2, &ms2) < 8) |
389 continue; | 389 continue; |
390 | 390 |
391 current->start = h1 * 360000 + m1 * 6000 + s1 * 100 + ms1 / 10; | 391 current->start = h1 * 360000 + m1 * 6000 + s1 * 100 + ms1 / 10; |
392 current->end = h2 * 360000 + m2 * 6000 + s2 * 100 + ms2 / 10; | 392 current->end = h2 * 360000 + m2 * 6000 + s2 * 100 + ms2 / 10; |
393 | 393 |
440 if (ass_enabled) | 440 if (ass_enabled) |
441 return sub_ass_read_line_subviewer(st, current, utf16); | 441 return sub_ass_read_line_subviewer(st, current, utf16); |
442 #endif | 442 #endif |
443 while (!current->text[0]) { | 443 while (!current->text[0]) { |
444 if (!stream_read_line (st, line, LINE_LEN, utf16)) return NULL; | 444 if (!stream_read_line (st, line, LINE_LEN, utf16)) return NULL; |
445 if ((len=sscanf (line, "%d:%d:%d%[,.:]%d --> %d:%d:%d%[,.:]%d",&a1,&a2,&a3,(char *)&i,&a4,&b1,&b2,&b3,(char *)&i,&b4)) < 10) | 445 if ((len=sscanf (line, "%d:%d:%d%*[,.:]%d --> %d:%d:%d%*[,.:]%d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)) < 8) |
446 continue; | 446 continue; |
447 current->start = a1*360000+a2*6000+a3*100+a4/10; | 447 current->start = a1*360000+a2*6000+a3*100+a4/10; |
448 current->end = b1*360000+b2*6000+b3*100+b4/10; | 448 current->end = b1*360000+b2*6000+b3*100+b4/10; |
449 for (i=0; i<SUB_MAX_TEXT;) { | 449 for (i=0; i<SUB_MAX_TEXT;) { |
450 int blank = 1; | 450 int blank = 1; |
1121 {*uses_time=0;return SUB_MICRODVD;} | 1121 {*uses_time=0;return SUB_MICRODVD;} |
1122 if (sscanf (line, "[%d][%d]", &i, &i)==2) | 1122 if (sscanf (line, "[%d][%d]", &i, &i)==2) |
1123 {*uses_time=1;return SUB_MPL2;} | 1123 {*uses_time=1;return SUB_MPL2;} |
1124 if (sscanf (line, "%d:%d:%d.%d,%d:%d:%d.%d", &i, &i, &i, &i, &i, &i, &i, &i)==8) | 1124 if (sscanf (line, "%d:%d:%d.%d,%d:%d:%d.%d", &i, &i, &i, &i, &i, &i, &i, &i)==8) |
1125 {*uses_time=1;return SUB_SUBRIP;} | 1125 {*uses_time=1;return SUB_SUBRIP;} |
1126 if (sscanf (line, "%d:%d:%d%[,.:]%d --> %d:%d:%d%[,.:]%d", &i, &i, &i, (char *)&i, &i, &i, &i, &i, (char *)&i, &i)==10) | 1126 if (sscanf (line, "%d:%d:%d%*[,.:]%d --> %d:%d:%d%*[,.:]%d", &i, &i, &i, &i, &i, &i, &i, &i)==8) |
1127 {*uses_time=1;return SUB_SUBVIEWER;} | 1127 {*uses_time=1;return SUB_SUBVIEWER;} |
1128 if (sscanf (line, "{T %d:%d:%d:%d",&i, &i, &i, &i)==4) | 1128 if (sscanf (line, "{T %d:%d:%d:%d",&i, &i, &i, &i)==4) |
1129 {*uses_time=1;return SUB_SUBVIEWER2;} | 1129 {*uses_time=1;return SUB_SUBVIEWER2;} |
1130 if (strstr (line, "<SAMI>")) | 1130 if (strstr (line, "<SAMI>")) |
1131 {*uses_time=1; return SUB_SAMI;} | 1131 {*uses_time=1; return SUB_SAMI;} |