LTTNG_ERR_NO_CONSUMER = 109, /* No consumer exist for the session */
LTTNG_ERR_EXCLUSION_INVAL = 110, /* Invalid event exclusion data */
LTTNG_ERR_EXCLUSION_NOMEM = 111, /* Lack of memory while processing event exclusions */
+ LTTNG_ERR_INVALID_EVENT_NAME = 112, /* Invalid event name */
/* MUST be last element */
LTTNG_ERR_NR, /* Last element */
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.
*/
assert(event);
assert(channel_name);
+ ret = validate_event_name(event->name);
+ if (ret) {
+ goto error;
+ }
+
rcu_read_lock();
switch (domain->type) {
[ ERROR_INDEX(LTTNG_ERR_MI_OUTPUT_TYPE) ] = "Invalid MI output format",
[ ERROR_INDEX(LTTNG_ERR_MI_IO_FAIL) ] = "IO error while writing MI output",
[ ERROR_INDEX(LTTNG_ERR_MI_NOT_IMPLEMENTED) ] = "Mi feature not implemented",
+ [ ERROR_INDEX(LTTNG_ERR_INVALID_EVENT_NAME) ] = "Invalid event name",
/* Last element */
[ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"