Disallow duplicate event exclusion names
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 26 Aug 2015 05:24:02 +0000 (01:24 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 4 Nov 2015 00:19:06 +0000 (19:19 -0500)
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 <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/trace-ust.c

index 178c7d04eb9f6f3ede96c59bdd82616975820168..4b7363f9fd2b15c6e4e1f05c9fe49cd58ff9f9c9 100644 (file)
@@ -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");
This page took 0.025657 seconds and 4 git commands to generate.