/*
- * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _LGPL_SOURCE
#include <common/compat/getenv.h>
#include <common/string-utils/string-utils.h>
#include <common/utils.h>
+#include <common/path.h>
#include <lttng/constant.h>
/* Mi dependancy */
#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;
/* Check for address */
match = sscanf(opt, "%" S_HEX_LEN_SCANF_IS_A_BROKEN_API "s", s_hex);
if (match > 0) {
- if (*s_hex == '\0') {
- ERR("Invalid probe address %s", s_hex);
+ /*
+ * Return an error if the first character of the tentative
+ * address is NULL or not a digit. It can be "0" if the address
+ * is in hexadecimal and can be 1 to 9 if it's in decimal.
+ */
+ if (*s_hex == '\0' || !isdigit(*s_hex)) {
+ ERR("Invalid probe description %s", s_hex);
ret = CMD_ERROR;
goto end;
}
* 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;
}
/* 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);
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;
}
ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace + opt_jul + opt_log4j + opt_python);
+ opt_kernel + opt_userspace + opt_jul + opt_log4j +
+ opt_python,
+ true);
if (ret) {
ret = CMD_ERROR;
goto end;
}
}
- 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;
}
+ 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);
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;
free(session_name);
}
+ free(event_list);
+
/* Overwrite ret if an error occurred in enable_events */
ret = command_ret ? command_ret : ret;