Both patches merged!

On 28 Aug (12:53:43), Jérémie Galarneau wrote:
> Not parenthesizing the clauses in a filter string causes JUL events to be
> traced even though they are not enabled when an enable-event command is
> issued with a filter and the --loglevel-only option.
> 
> For instance,
> 
> lttng enable-event -j "my_event" --loglevel-only JUL_CONFIG -f "int_loglevel 
> > 0 || int_loglevel < 0"
> 
> results in the following filter being applied:
> 
> int_loglevel > 0 || int_loglevel < 0 && logger_name == "my_event" && 
> int_loglevel == 700
> 
> The resulting expression will always evaluate to true, regardless of the 
> logger
> name.
> 
> This fix parenthesizes each clause to ensure they are all independently
> evaluated and not unintuitively affected by operator precedence.
> 
> Signed-off-by: Jérémie Galarneau <[email protected]>
> ---
>  src/lib/lttng-ctl/lttng-ctl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c
> index 9686b7d..f83d053 100644
> --- a/src/lib/lttng-ctl/lttng-ctl.c
> +++ b/src/lib/lttng-ctl/lttng-ctl.c
> @@ -705,7 +705,7 @@ static char *set_jul_filter(const char *filter, struct 
> lttng_event *ev)
>       /* Don't add filter for the '*' event. */
>       if (ev->name[0] != '*') {
>               if (filter) {
> -                     err = asprintf(&jul_filter, "%s && logger_name == 
> \"%s\"", filter,
> +                     err = asprintf(&jul_filter, "(%s) && (logger_name == 
> \"%s\")", filter,
>                                       ev->name);
>               } else {
>                       err = asprintf(&jul_filter, "logger_name == \"%s\"", 
> ev->name);
> @@ -729,7 +729,7 @@ static char *set_jul_filter(const char *filter, struct 
> lttng_event *ev)
>               if (filter || jul_filter) {
>                       char *new_filter;
>  
> -                     err = asprintf(&new_filter, "%s && int_loglevel %s %d",
> +                     err = asprintf(&new_filter, "(%s) && (int_loglevel %s 
> %d)",
>                                       jul_filter ? jul_filter : filter, op,
>                                       ev->loglevel);
>                       if (jul_filter) {
> -- 
> 2.1.0
> 

Attachment: signature.asc
Description: Digital signature

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Reply via email to