projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: lttng: poptGetArg doesn't provide string ownership
[lttng-tools.git]
/
src
/
bin
/
lttng
/
commands
/
enable_events.c
diff --git
a/src/bin/lttng/commands/enable_events.c
b/src/bin/lttng/commands/enable_events.c
index 8dc44a1fca1a6bb027950524bbf9f5eced3cae16..a833c23ad4a3fe7162867ca41803633276a541f8 100644
(file)
--- a/
src/bin/lttng/commands/enable_events.c
+++ b/
src/bin/lttng/commands/enable_events.c
@@
-33,7
+33,6
@@
#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
#endif
#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
#endif
-static char *opt_event_list;
static int opt_event_type;
static const char *opt_loglevel;
static int opt_loglevel_type;
static int opt_event_type;
static const char *opt_loglevel;
static int opt_loglevel_type;
@@
-962,7
+961,7
@@
static void warn_on_truncated_exclusion_names(char * const *exclusion_list,
* Enabling event using the lttng API.
* Note: in case of error only the last error code will be return.
*/
* Enabling event using the lttng API.
* Note: in case of error only the last error code will be return.
*/
-static int enable_events(char *session_name)
+static int enable_events(char *session_name
, char *event_list
)
{
int ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
int error_holder = CMD_SUCCESS, warn = 0, error = 0, success = 1;
{
int ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
int error_holder = CMD_SUCCESS, warn = 0, error = 0, success = 1;
@@
-1326,7
+1325,7
@@
static int enable_events(char *session_name)
}
/* Strip event list */
}
/* Strip event list */
- event_name = strtok(
opt_
event_list, ",");
+ event_name = strtok(event_list, ",");
while (event_name != NULL) {
/* Copy name and type of the event */
strncpy(ev->name, event_name, LTTNG_SYMBOL_NAME_LEN);
while (event_name != NULL) {
/* Copy name and type of the event */
strncpy(ev->name, event_name, LTTNG_SYMBOL_NAME_LEN);
@@
-1708,6
+1707,8
@@
int cmd_enable_events(int argc, const char **argv)
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
char *session_name = NULL;
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
char *session_name = NULL;
+ char *event_list = NULL;
+ const char *arg_event_list = NULL;
const char *leftover = NULL;
int event_type = -1;
const char *leftover = NULL;
int event_type = -1;
@@
-1806,13
+1807,22
@@
int cmd_enable_events(int argc, const char **argv)
}
}
}
}
-
opt_event_list = (char*)
poptGetArg(pc);
- if (
opt
_event_list == NULL && opt_enable_all == 0) {
- ERR("Missing event name(s).
\n
");
+
arg_event_list =
poptGetArg(pc);
+ if (
arg
_event_list == NULL && opt_enable_all == 0) {
+ ERR("Missing event name(s).");
ret = CMD_ERROR;
goto end;
}
ret = CMD_ERROR;
goto end;
}
+ if (opt_enable_all == 0) {
+ event_list = strdup(arg_event_list);
+ if (event_list == NULL) {
+ PERROR("Failed to copy event name(s)");
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+
leftover = poptGetArg(pc);
if (leftover) {
ERR("Unknown argument: %s", leftover);
leftover = poptGetArg(pc);
if (leftover) {
ERR("Unknown argument: %s", leftover);
@@
-1831,7
+1841,7
@@
int cmd_enable_events(int argc, const char **argv)
session_name = opt_session_name;
}
session_name = opt_session_name;
}
- command_ret = enable_events(session_name);
+ command_ret = enable_events(session_name
, event_list
);
if (command_ret) {
success = 0;
goto mi_closing;
if (command_ret) {
success = 0;
goto mi_closing;
@@
-1873,6
+1883,8
@@
end:
free(session_name);
}
free(session_name);
}
+ free(event_list);
+
/* Overwrite ret if an error occurred in enable_events */
ret = command_ret ? command_ret : ret;
/* Overwrite ret if an error occurred in enable_events */
ret = command_ret ? command_ret : ret;
This page took
0.024788 seconds
and
4
git commands to generate.