From: Philippe Proulx Date: Wed, 26 Aug 2015 05:24:02 +0000 (-0400) Subject: Disallow duplicate event exclusion names X-Git-Tag: v2.8.0-rc1~232 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=ad11a1d34b25fced1b5bcb0494016d3041d9bb8b Disallow duplicate event exclusion names This patch makes the session daemon disallow event exclusion names sharing the same name when creating an UST event, e.g.: lttng enable-event -u -a a,b,c,d -> allowed lttng enable-event -u -a a,b,a,d -> disallowed Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 178c7d04e..4b7363f9f 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -359,6 +359,39 @@ error: return luc; } +/* + * Validates an exclusion list. + * + * Returns 0 if valid, negative value if invalid. + */ +static int validate_exclusion(struct lttng_event_exclusion *exclusion) +{ + size_t i; + int ret = 0; + + assert(exclusion); + + for (i = 0; i < exclusion->count; ++i) { + size_t j; + const char *name_a = + LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, i); + + for (j = 0; j < i; ++j) { + const char *name_b = + LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, j); + + if (!strncmp(name_a, name_b, LTTNG_SYMBOL_NAME_LEN)) { + /* Match! */ + ret = -1; + goto end; + } + } + } + +end: + return ret; +} + /* * Allocate and initialize a ust event. Set name and event type. * We own filter_expression, filter, and exclusion. @@ -375,6 +408,10 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, assert(ev); + if (exclusion && validate_exclusion(exclusion)) { + goto error; + } + lue = zmalloc(sizeof(struct ltt_ust_event)); if (lue == NULL) { PERROR("ust event zmalloc");