projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: sessiond: ODR violation results in memory corruption
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
agent.cpp
diff --git
a/src/bin/lttng-sessiond/agent.cpp
b/src/bin/lttng-sessiond/agent.cpp
index ed8a8d12607aad0c2e7d45fd43485f11071de0ba..2a880a19c800722a6f3bc4c785f43632e61aef28 100644
(file)
--- a/
src/bin/lttng-sessiond/agent.cpp
+++ b/
src/bin/lttng-sessiond/agent.cpp
@@
-39,6
+39,7
@@
typedef enum lttng_event_rule_status (*event_rule_logging_get_log_level_rule)(
/*
* Agent application context representation.
*/
/*
* Agent application context representation.
*/
+namespace {
struct agent_app_ctx {
char *provider_name;
char *ctx_name;
struct agent_app_ctx {
char *provider_name;
char *ctx_name;
@@
-49,6
+50,7
@@
struct agent_app_ctx {
/* For call_rcu teardown. */
struct rcu_head rcu_node;
};
/* For call_rcu teardown. */
struct rcu_head rcu_node;
};
+} /* namespace */
/*
* Human readable agent return code.
/*
* Human readable agent return code.
@@
-348,7
+350,7
@@
static ssize_t list_events(struct agent_app *app, struct lttng_event **events)
goto error;
}
goto error;
}
- reply =
(lttcomm_agent_list_reply *) zmalloc
(data_size);
+ reply =
zmalloc<lttcomm_agent_list_reply>
(data_size);
if (!reply) {
ret = LTTNG_ERR_NOMEM;
goto error;
if (!reply) {
ret = LTTNG_ERR_NOMEM;
goto error;
@@
-361,7
+363,7
@@
static ssize_t list_events(struct agent_app *app, struct lttng_event **events)
}
nb_event = be32toh(reply->nb_event);
}
nb_event = be32toh(reply->nb_event);
- tmp_events =
(lttng_event *) zmalloc(sizeof(*tmp_events) *
nb_event);
+ tmp_events =
calloc<lttng_event>(
nb_event);
if (!tmp_events) {
ret = LTTNG_ERR_NOMEM;
goto error;
if (!tmp_events) {
ret = LTTNG_ERR_NOMEM;
goto error;
@@
-441,7
+443,7
@@
static int enable_event(const struct agent_app *app, struct agent_event *event)
goto error_io;
}
goto error_io;
}
- bytes_to_send =
(char *) zmalloc
(data_size);
+ bytes_to_send =
calloc<char>
(data_size);
if (!bytes_to_send) {
ret = LTTNG_ERR_NOMEM;
goto error;
if (!bytes_to_send) {
ret = LTTNG_ERR_NOMEM;
goto error;
@@
-726,7
+728,7
@@
struct agent_app_ctx *create_app_ctx(const struct lttng_event_context *ctx)
}
LTTNG_ASSERT(ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT);
}
LTTNG_ASSERT(ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT);
- agent_ctx =
(agent_app_ctx *) zmalloc(sizeof(*ctx)
);
+ agent_ctx =
zmalloc<agent_app_ctx>(
);
if (!agent_ctx) {
goto end;
}
if (!agent_ctx) {
goto end;
}
@@
-898,7
+900,7
@@
int agent_list_events(struct lttng_event **events,
DBG2("Agent listing events for domain %d", domain);
nbmem = UST_APP_EVENT_LIST_SIZE;
DBG2("Agent listing events for domain %d", domain);
nbmem = UST_APP_EVENT_LIST_SIZE;
- tmp_events =
(lttng_event *) zmalloc(nbmem * sizeof(*tmp_events)
);
+ tmp_events =
calloc<lttng_event>(nbmem
);
if (!tmp_events) {
PERROR("zmalloc agent list events");
ret = -ENOMEM;
if (!tmp_events) {
PERROR("zmalloc agent list events");
ret = -ENOMEM;
@@
-974,7
+976,7
@@
struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
LTTNG_ASSERT(sock);
LTTNG_ASSERT(sock);
- app =
(agent_app *) zmalloc(sizeof(*app)
);
+ app =
zmalloc<agent_app>(
);
if (!app) {
PERROR("Failed to allocate agent application instance");
goto error;
if (!app) {
PERROR("Failed to allocate agent application instance");
goto error;
@@
-1117,7
+1119,7
@@
struct agent *agent_create(enum lttng_domain_type domain)
int ret;
struct agent *agt;
int ret;
struct agent *agt;
- agt =
(agent *) zmalloc(sizeof(struct agent)
);
+ agt =
zmalloc<agent>(
);
if (!agt) {
goto error;
}
if (!agt) {
goto error;
}
@@
-1156,7
+1158,7
@@
struct agent_event *agent_create_event(const char *name,
goto error;
}
goto error;
}
- event =
(agent_event *) zmalloc(sizeof(*event)
);
+ event =
zmalloc<agent_event>(
);
if (!event) {
goto error;
}
if (!event) {
goto error;
}
This page took
0.025013 seconds
and
4
git commands to generate.