summaryrefslogtreecommitdiff
path: root/libavcodec/htmlsubtitles.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-07-02 00:09:42 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-07-18 22:14:16 +0200
commitc61715e2c505c15a5cfc9eab18b4311a6504055a (patch)
treee00db95db9a6962809ecdec5f218c84e99f16284 /libavcodec/htmlsubtitles.c
parent2886142e0c3b5f4304c6e2a2bd282770a8a47f93 (diff)
avcodec/htmlsubtitles: Be a bit more picky on syntax
This reduces the number of strstr() calls per byte This diasalows empty tags like '< >' as well as '<' in tags like '<ab<cd<<ef>' Fixes timeout Fixes: 1817/clusterfuzz-testcase-minimized-5104230530547712 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/htmlsubtitles.c')
-rw-r--r--libavcodec/htmlsubtitles.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c
index 9575464063..e6bac713c1 100644
--- a/libavcodec/htmlsubtitles.c
+++ b/libavcodec/htmlsubtitles.c
@@ -110,13 +110,13 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
case '<':
tag_close = in[1] == '/';
len = 0;
- if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
+ if (sscanf(in+tag_close+1, "%127[^<>]>%n", buffer, &len) >= 1 && len > 0) {
const char *tagname = buffer;
while (*tagname == ' ')
tagname++;
if ((param = strchr(tagname, ' ')))
*param++ = 0;
- if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
+ if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack) && *tagname) ||
( tag_close && sptr > 0 && !av_strcasecmp(stack[sptr-1].tag, tagname))) {
int i, j, unknown = 0;
in += len + tag_close;