*
* Linux Trace Toolkit Control Library
*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
* Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* SPDX-License-Identifier: LGPL-2.1-only
in_tgroup = lttng_check_tracing_group();
}
- if ((uid == 0) || in_tgroup) {
+ if ((uid == 0) || in_tgroup == 1) {
const int ret = lttng_strncpy(sessiond_sock_path,
DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
sizeof(sessiond_sock_path));
for (i = 0; i < exclusion_count; i++) {
size_t exclusion_len;
- exclusion_len = lttng_strnlen(*(exclusion_list + i),
+ exclusion_len = lttng_strnlen(exclusion_list[i],
LTTNG_SYMBOL_NAME_LEN);
if (exclusion_len == LTTNG_SYMBOL_NAME_LEN) {
/* Exclusion is not NULL-terminated. */
}
ret = lttng_dynamic_buffer_append(&payload.buffer,
- *(exclusion_list + i), LTTNG_SYMBOL_NAME_LEN);
+ exclusion_list[i], exclusion_len);
+ if (ret) {
+ goto mem_error;
+ }
+
+ /*
+ * Padding the rest of the entry with zeros. Every exclusion
+ * entries take LTTNG_SYMBOL_NAME_LEN bytes in the buffer.
+ */
+ ret = lttng_dynamic_buffer_set_size(&payload.buffer,
+ LTTNG_SYMBOL_NAME_LEN * (i + 1));
if (ret) {
goto mem_error;
}
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTNG_LIST_SESSIONS;
+ /*
+ * Initialize out_sessions to NULL so it is initialized when
+ * lttng_list_sessions returns 0, thus allowing *out_sessions to
+ * be subsequently freed.
+ */
+ *out_sessions = NULL;
ret = lttng_ctl_ask_sessiond(&lsm, (void**) &sessions);
if (ret <= 0) {
goto end;
if (ret % session_size) {
ret = -LTTNG_ERR_UNK;
free(sessions);
- *out_sessions = NULL;
goto end;
}
session_count = (size_t) ret / session_size;
*/
int lttng_set_tracing_group(const char *name)
{
+ char *new_group;
if (name == NULL) {
return -LTTNG_ERR_INVALID;
}
- if (asprintf(&tracing_group, "%s", name) < 0) {
+ if (asprintf(&new_group, "%s", name) < 0) {
return -LTTNG_ERR_FATAL;
}
+ free(tracing_group);
+ tracing_group = new_group;
+ new_group = NULL;
+
return 0;
}