Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2013-09-08 20:02:45 +0400
committerClément Bœsch <u@pkh.me>2013-09-08 20:48:09 +0400
commit90fc00a623de44e137fe1601b91356e8cd8bdd54 (patch)
tree1673c23b8d12b4e706725aa739bd98e11dfc936c /libavformat/srtdec.c
parentcfcd55db164e0acc0c30b2cf084e6eebe9741d34 (diff)
avformat/subtitles: add a next line jumper and use it.
This fixes a bunch of possible overread in avformat with the idiom p += strcspn(p, "\n") + 1 (strcspn() can focus on the trailing '\0' if no '\n' is found, so the +1 leads to an overread). Note on lavf/matroskaenc: no extra subtitles.o Makefile dependency is added because only the header is required for ff_subtitles_next_line(). Note on lavf/mpsubdec: code gets slightly complex to avoid an infinite loop in the probing since there is no more forced increment.
Diffstat (limited to 'libavformat/srtdec.c')
-rw-r--r--libavformat/srtdec.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c
index ac783d9e3b..7f911bd05b 100644
--- a/libavformat/srtdec.c
+++ b/libavformat/srtdec.c
@@ -44,7 +44,7 @@ static int srt_probe(AVProbeData *p)
&& sscanf(ptr, "%*d:%*2d:%*2d%*1[,.]%*3d --> %*d:%*2d:%*2d%*1[,.]%3d", &v) == 1)
return AVPROBE_SCORE_MAX;
num = atoi(ptr);
- ptr += strcspn(ptr, "\n") + 1;
+ ptr += ff_subtitles_next_line(ptr);
}
return 0;
}
@@ -65,12 +65,10 @@ static int64_t get_pts(const char **buf, int *duration,
int64_t start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1;
int64_t end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2;
*duration = end - start;
- *buf += strcspn(*buf, "\n");
- *buf += !!**buf;
+ *buf += ff_subtitles_next_line(*buf);
return start;
}
- *buf += strcspn(*buf, "\n");
- *buf += !!**buf;
+ *buf += ff_subtitles_next_line(*buf);
}
return AV_NOPTS_VALUE;
}