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

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
63 63
64 name = av_get_token(buf, "]");64 name = av_get_token(buf, "]");
65 if (!name)65 if (!name)
66 goto fail;66 return NULL;
67 67
68 if (!name[0]) {68 if (!name[0]) {
69 av_log(log_ctx, AV_LOG_ERROR,69 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
71 goto fail;71 goto fail;
72 }72 }
73 73
74 if (*(*buf)++ != ']') {74 if (**buf != ']') {
75 av_log(log_ctx, AV_LOG_ERROR,75 av_log(log_ctx, AV_LOG_ERROR,
76 "Mismatched '[' found in the following: \"%s\".\n", start);76 "Mismatched '[' found in the following: \"%s\".\n", start);
77 fail:77 fail:
78 av_freep(&name);78 av_freep(&name);
79 return NULL;
79 }80 }
81 (*buf)++;
80 82
81 return name;83 return name;
82}84}

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