History

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.

Andreas Rheinhardt committed 6 years ago

Commit f33faa51 parent b3f6dee1 file · +4 −2Browse files

Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all

Unified · Split

libavfilter/graphparser.c+4−2
@@ -63,7 +63,7 @@ static char *parse_link_name(const char **buf, void *log_ctx) · 62 unmodified lines
6363
6464 name = av_get_token(buf, "]");
6565 if (!name)
66− goto fail;
66+ return NULL;
6767
6868 if (!name[0]) {
6969 av_log(log_ctx, AV_LOG_ERROR,
@@ -71,12 +71,14 @@ static char *parse_link_name(const char **buf, void *log_ctx) · 1 unmodified line
7171 goto fail;
7272 }
7373
74− if (*(*buf)++ != ']') {
74+ if (**buf != ']') {
7575 av_log(log_ctx, AV_LOG_ERROR,
7676 "Mismatched '[' found in the following: \"%s\".\n", start);
7777 fail:
7878 av_freep(&name);
79+ return NULL;
7980 }
81+ (*buf)++;
8082
8183 return name;
8284 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t