lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9e9a550c-0017-40b0-af14-99f3c926290c@linaro.org>
Date: Mon, 9 Dec 2024 11:49:15 +0000
From: James Clark <james.clark@...aro.org>
To: Ian Rogers <irogers@...gle.com>,
 Arnaldo Carvalho de Melo <acme@...nel.org>,
 Namhyung Kim <namhyung@...nel.org>,
 "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
 Mark Rutland <mark.rutland@....com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Jiri Olsa <jolsa@...nel.org>, Adrian Hunter <adrian.hunter@...el.com>,
 Kan Liang <kan.liang@...ux.intel.com>, Peter Zijlstra
 <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH v1] perf string: Avoid undefined NULL+1



On 20/11/2024 6:52 am, Ian Rogers wrote:
> While the value NULL+1 is never used it triggers a ubsan
> warning. Restructure and comment the loop to avoid this.
> 
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>   tools/perf/util/string.c | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
> index 308fc7ec88cc..c0e927bbadf6 100644
> --- a/tools/perf/util/string.c
> +++ b/tools/perf/util/string.c
> @@ -254,11 +254,20 @@ char *strpbrk_esc(char *str, const char *stopset)
>   
>   	do {
>   		ptr = strpbrk(str, stopset);
> -		if (ptr == str ||
> -		    (ptr == str + 1 && *(ptr - 1) != '\\'))
> +		if (!ptr) {
> +			/* stopset not in str. */
>   			break;
> +		}
> +		if (ptr == str) {
> +			/* stopset character is first in str. */
> +			break;
> +		}
> +		if (ptr == str + 1 && str[0] != '\\') {
> +			/* stopset chacter is second and wasn't preceded by a '\'. */
> +			break;
> +		}
>   		str = ptr + 1;
> -	} while (ptr && *(ptr - 1) == '\\' && *(ptr - 2) != '\\');
> +	} while (ptr[-1] == '\\' && ptr[-2] != '\\');
>   
>   	return ptr;
>   }

Reviewed-by: James Clark <james.clark@...aro.org>



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ