mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] [perf] lsdir_bid_tail_filter: fix index check
@ 2020-06-24  1:35 Gaurav Singh
  2020-06-24 12:50 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Singh @ 2020-06-24  1:35 UTC (permalink / raw)
  To: gaurav1086, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, open list:PERFORMANCE EVENTS SUBSYSTEM

Check bounds before accessing d->d_name[].

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 tools/perf/util/build-id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index c076fc7fe025..8c35cbe93f10 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -431,7 +431,7 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
 				  struct dirent *d)
 {
 	int i = 0;
-	while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3)
+	while (i < SBUILD_ID_SIZE - 3 && isxdigit(d->d_name[i]))
 		i++;
 	return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0');
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [perf] lsdir_bid_tail_filter: fix index check
  2020-06-24  1:35 [PATCH] [perf] lsdir_bid_tail_filter: fix index check Gaurav Singh
@ 2020-06-24 12:50 ` Jiri Olsa
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2020-06-24 12:50 UTC (permalink / raw)
  To: Gaurav Singh
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim,
	open list:PERFORMANCE EVENTS SUBSYSTEM

On Tue, Jun 23, 2020 at 09:35:22PM -0400, Gaurav Singh wrote:
> Check bounds before accessing d->d_name[].
> 
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
> ---
>  tools/perf/util/build-id.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> index c076fc7fe025..8c35cbe93f10 100644
> --- a/tools/perf/util/build-id.c
> +++ b/tools/perf/util/build-id.c
> @@ -431,7 +431,7 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
>  				  struct dirent *d)
>  {
>  	int i = 0;
> -	while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3)
> +	while (i < SBUILD_ID_SIZE - 3 && isxdigit(d->d_name[i]))

hum, I guess it looks better, but technicaly this is not a problem right?

isxdigit will return false on zero byte which is always present in d->d_name
so it will never get out of bounds

jirka

>  		i++;
>  	return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0');
>  }
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-24 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24  1:35 [PATCH] [perf] lsdir_bid_tail_filter: fix index check Gaurav Singh
2020-06-24 12:50 ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®