diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-08-23 00:31:17 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-08-23 19:57:42 +0200 |
commit | f33faa5b9bfb288f83db034fa1f8719ab8a994c6 (patch) | |
tree | df8e9bfbc626e32904b7bdcb764ad8c4cc9f509b | |
parent | b3f6dee728c2741388638f8343379bf0f0ef5946 (diff) | |
download | ffmpeg-f33faa5b9bfb288f83db034fa1f8719ab8a994c6.tar.gz |
avfilter/graphparser: Don't set pointer to one beyond '\0' of string
This happened in parse_link_name() if there was a '[' without matching
']'. While this is not undefined behaviour (pointer arithmetic one
beyond the end of an array works fine as long as there are no accesses),
it is potentially dangerous. It currently isn't (all callers of
parse_link_name() treat this as an error and don't access the string any
more), but making sure that this will never cause trouble in the future
seems nevertheless worthwhile.
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r-- | libavfilter/graphparser.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index dfb94788e1..e96b20418e 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -63,7 +63,7 @@ static char *parse_link_name(const char **buf, void *log_ctx) name = av_get_token(buf, "]"); if (!name) - goto fail; + return NULL; if (!name[0]) { av_log(log_ctx, AV_LOG_ERROR, @@ -71,12 +71,14 @@ static char *parse_link_name(const char **buf, void *log_ctx) goto fail; } - if (*(*buf)++ != ']') { + if (**buf != ']') { av_log(log_ctx, AV_LOG_ERROR, "Mismatched '[' found in the following: \"%s\".\n", start); fail: av_freep(&name); + return NULL; } + (*buf)++; return name; } |