Fix: save: leak of configuration file fd
[lttng-tools.git] / src / bin / lttng-sessiond / save.c
index 59cd1e171cfba6953047b916c1e65b47d14d89a8..c3db2882ad589316ac15760d89ecd5439ae71352 100644 (file)
@@ -693,7 +693,11 @@ int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event,
 
        ust_event->enabled = agent_event->enabled;
        ust_event->attr.instrumentation = LTTNG_UST_TRACEPOINT;
-       strncpy(ust_event->attr.name, agent_event->name, LTTNG_SYMBOL_NAME_LEN);
+       if (lttng_strncpy(ust_event->attr.name, agent_event->name,
+                       LTTNG_SYMBOL_NAME_LEN)) {
+               ret = -1;
+               goto end;
+       }
        switch (agent_event->loglevel_type) {
        case LTTNG_EVENT_LOGLEVEL_ALL:
                ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
@@ -956,8 +960,8 @@ int save_ust_context(struct config_writer *writer,
                        context_type_string = get_ust_context_type_string(
                                ctx->ctx.ctx);
                        if (!context_type_string) {
-                               ERR("Unsupported UST context type.")
-                                       ret = LTTNG_ERR_INVALID;
+                               ERR("Unsupported UST context type.");
+                               ret = LTTNG_ERR_INVALID;
                                goto end;
                        }
 
@@ -1963,6 +1967,13 @@ end:
                }
        }
 
+       if (file_opened) {
+               ret = close(fd);
+               if (ret) {
+                       PERROR("Closing XML session configuration");
+               }
+       }
+
        return ret;
 }
 
This page took 0.023743 seconds and 4 git commands to generate.