[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YzIC3EpZaDNQlFOe@kernel.org>
Date: Mon, 26 Sep 2022 20:51:56 +0100
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Chen Zhongjin <chenzhongjin@...wei.com>
Cc: linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
peterz@...radead.org, mingo@...hat.com, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
namhyung@...nel.org, irogers@...gle.com, john.garry@...wei.com,
adrian.hunter@...el.com, ak@...ux.intel.com,
florian.fischer@...q.space
Subject: Re: [PATCH -next 2/5] perf: Fix incorrectly parsed flags in filter
Em Mon, Sep 26, 2022 at 11:14:37AM +0800, Chen Zhongjin escreveu:
> When parsing flags in filter, the strtoul function uses wrong parsing
> condition (tok[1] = 'x'), which can make the flags be corrupted and
> treat all numbers start with 0 as hex.
>
> In fact strtoul() will auto test hex format when base == 0 (See
> _parse_integer_fixup_radix). So there is no need to test this again.
>
> Remove the unnessesary is_hexa test.
Thanks, applied.
- Arnaldo
> Fixes: 154c978d484c ("libbeauty: Introduce strarray__strtoul_flags()")
> Signed-off-by: Chen Zhongjin <chenzhongjin@...wei.com>
> ---
> tools/perf/builtin-trace.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index c7bb7a8222a6..7ecd76428440 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -615,11 +615,8 @@ bool strarray__strtoul_flags(struct strarray *sa, char *bf, size_t size, u64 *re
> if (isalpha(*tok) || *tok == '_') {
> if (!strarray__strtoul(sa, tok, toklen, &val))
> return false;
> - } else {
> - bool is_hexa = tok[0] == 0 && (tok[1] = 'x' || tok[1] == 'X');
> -
> - val = strtoul(tok, NULL, is_hexa ? 16 : 0);
> - }
> + } else
> + val = strtoul(tok, NULL, 0);
>
> *ret |= (1 << (val - 1));
>
> --
> 2.17.1
--
- Arnaldo
Powered by blists - more mailing lists