diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-07-02 00:09:42 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-05-14 00:17:29 +0200 |
commit | abdbbe895838a55a404d54f7b26a4aca23d19577 (patch) | |
tree | 4b0d04e1233302527111578c4266dc78a1718f96 | |
parent | 3a6bcc059cc61b13502401ae34a5aeef016ae061 (diff) | |
download | ffmpeg-abdbbe895838a55a404d54f7b26a4aca23d19577.tar.gz |
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>
(cherry picked from commit c61715e2c505c15a5cfc9eab18b4311a6504055a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/htmlsubtitles.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c index 70311c66d5..4c9e4f3e76 100644 --- a/libavcodec/htmlsubtitles.c +++ b/libavcodec/htmlsubtitles.c @@ -102,13 +102,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 && !strcmp(stack[sptr-1].tag, tagname))) { int i, j, unknown = 0; in += len + tag_close; |