X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=0cc71303aeb6704de4bc926f39d0e2acbf58bc39;hb=930a2e995548ba32bfe27d996e306a07f1129b8a;hp=044e9eefec7e14eab9eb1046411395d1ccdebdff;hpb=68808f4e0bbb3adccff72ff9dab6ec9f3a9e6866;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 044e9eefe..0cc71303a 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1301,6 +1301,38 @@ error: return ret; } +static int validate_event_name(const char *name) +{ + int ret = 0; + const char *c = name; + const char *event_name_end = c + LTTNG_SYMBOL_NAME_LEN; + + /* + * Make sure that unescaped wildcards are only used as the last + * character of the event name. + */ + while (c < event_name_end) { + switch (*c) { + case '\0': + goto end; + case '\\': + c++; + break; + case '*': + if ((c + 1) < event_name_end && *(c + 1)) { + /* Wildcard is not the last character */ + ret = LTTNG_ERR_INVALID_EVENT_NAME; + goto end; + } + default: + break; + } + c++; + } +end: + return ret; +} + /* * Command LTTNG_ENABLE_EVENT processed by the client thread. */ @@ -1318,6 +1350,11 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, assert(event); assert(channel_name); + ret = validate_event_name(event->name); + if (ret) { + goto error; + } + rcu_read_lock(); switch (domain->type) {