X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fenable_events.c;h=18793ae095a77cbe8365f09ac0576a06011ea407;hb=6dc3064a30b0cc7cfa9fdd22da1963525dfb7388;hp=57837eb7dcadd3828110b7a7f386460ad491a570;hpb=de044b7a0613db6d16151ac9f7b7be404c0bb493;p=lttng-tools.git diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 57837eb7d..18793ae09 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -268,7 +268,11 @@ int loglevel_str_to_value(const char *inputstr) int i = 0; char str[LTTNG_SYMBOL_NAME_LEN]; - while (i < LTTNG_SYMBOL_NAME_LEN && inputstr[i] != '\0') { + /* + * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is + * added at the end of the loop so a the upper bound we avoid the overflow. + */ + while (i < (LTTNG_SYMBOL_NAME_LEN - 1) && inputstr[i] != '\0') { str[i] = toupper(inputstr[i]); i++; } @@ -438,7 +442,6 @@ static int enable_events(char *session_name) ret = lttng_enable_event_with_filter(handle, &ev, channel_name, opt_filter); if (ret < 0) { - fprintf(stderr, "Ret filter: %d\n", ret); switch (-ret) { case LTTNG_ERR_FILTER_EXIST: WARN("Filter on events is already enabled" @@ -447,9 +450,8 @@ static int enable_events(char *session_name) break; case LTTNG_ERR_FILTER_INVAL: case LTTNG_ERR_FILTER_NOMEM: - ERR("%s", lttng_strerror(ret)); default: - ERR("Setting filter: '%s'", opt_filter); + ERR("%s", lttng_strerror(ret)); break; } goto error;