[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Yyy1JgWCuQTMKFkY@kernel.org>
Date: Thu, 22 Sep 2022 20:19:02 +0100
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: cgel.zte@...il.com
Cc: mingo@...hat.com, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
namhyung@...nel.org, irogers@...gle.com, songliubraving@...com,
adrian.hunter@...el.com, davemarchevsky@...com, wcohen@...hat.com,
andres@...razel.de, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, ye xingchen <ye.xingchen@....com.cn>,
Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH linux-next] perf annotate: use strscpy() is more robust
and safer
Em Thu, Sep 22, 2022 at 01:24:31AM +0000, cgel.zte@...il.com escreveu:
> From: ye xingchen <ye.xingchen@....com.cn>
>
> The implementation of strscpy() is more robust and safer.
Where is strscpy() defined?
I see it defined in the kernel:
⬢[acme@...lbox perf]$ grep -w strscpy include/linux/string.h
ssize_t strscpy(char *, const char *, size_t);
/* Wraps calls to strscpy()/memset(), no arch specific code required */
⬢[acme@...lbox perf]$
But not in tools/
Have you actually build with these patches?
- Arnaldo
> That's now the recommended way to copy NUL terminated strings.
>
> Reported-by: Zeal Robot <zealci@....com.cn>
> Signed-off-by: ye xingchen <ye.xingchen@....com.cn>
> ---
> tools/perf/util/annotate.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 5bc63c9e0324..e2b038b14ff6 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -1702,7 +1702,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
> char *new_name = filename_with_chroot(dso->nsinfo->pid,
> filename);
> if (new_name) {
> - strlcpy(filename, new_name, filename_size);
> + strscpy(filename, new_name, filename_size);
> free(new_name);
> }
> }
> @@ -2002,7 +2002,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
> kce.len = sym->end - sym->start;
> if (!kcore_extract__create(&kce)) {
> delete_extract = true;
> - strlcpy(symfs_filename, kce.extract_filename,
> + strscpy(symfs_filename, kce.extract_filename,
> sizeof(symfs_filename));
> }
> } else if (dso__needs_decompress(dso)) {
> --
> 2.25.1
--
- Arnaldo
Powered by blists - more mailing lists