BPF Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] tools lib api fs: fix gcc9 compilation error
@ 2019-12-11  8:01 Andrey Zhizhikin
  2019-12-17 21:21 ` Andrey Zhizhikin
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Andrey Zhizhikin @ 2019-12-11  8:01 UTC (permalink / raw)
  To: ast, daniel, kafai, songliubraving, yhs, andriin,
	sergey.senozhatsky, pmladek, wangkefeng.wang, linux-kernel,
	netdev, bpf
  Cc: Andrey Zhizhikin, Arnaldo Carvalho de Melo, Jiri Olsa

GCC9 introduced string hardening mechanisms, which exhibits the error
during fs api compilation:

error: '__builtin_strncpy' specified bound 4096 equals destination size
[-Werror=stringop-truncation]

This comes when the length of copy passed to strncpy is is equal to
destination size, which could potentially lead to buffer overflow.

There is a need to mitigate this potential issue by limiting the size of
destination by 1 and explicitly terminate the destination with NULL.

Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/fs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 11b3885e833e..027b18f7ed8c 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
 	size_t name_len = strlen(fs->name);
 	/* name + "_PATH" + '\0' */
 	char upper_name[name_len + 5 + 1];
+
 	memcpy(upper_name, fs->name, name_len);
 	mem_toupper(upper_name, name_len);
 	strcpy(&upper_name[name_len], "_PATH");
@@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
 		return false;
 
 	fs->found = true;
-	strncpy(fs->path, override_path, sizeof(fs->path));
+	strncpy(fs->path, override_path, sizeof(fs->path) - 1);
+	fs->path[sizeof(fs->path) - 1] = '\0';
 	return true;
 }
 
-- 
2.17.1


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

* Re: [PATCH] tools lib api fs: fix gcc9 compilation error
  2019-12-11  8:01 [PATCH] tools lib api fs: fix gcc9 compilation error Andrey Zhizhikin
@ 2019-12-17 21:21 ` Andrey Zhizhikin
  2019-12-18  3:10 ` Sergey Senozhatsky
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andrey Zhizhikin @ 2019-12-17 21:21 UTC (permalink / raw)
  To: ast, daniel, kafai, songliubraving, yhs, andriin,
	sergey.senozhatsky, pmladek, wangkefeng.wang, linux-kernel,
	netdev, bpf
  Cc: Andrey Zhizhikin, Arnaldo Carvalho de Melo, Jiri Olsa

Hello all,

I'd like to have a gentle ping on this patch, if someone could review
and apply it - I'd really appreciate it.

On Wed, Dec 11, 2019 at 9:01 AM Andrey Zhizhikin <andrey.z@gmail.com> wrote:
>
> GCC9 introduced string hardening mechanisms, which exhibits the error
> during fs api compilation:
>
> error: '__builtin_strncpy' specified bound 4096 equals destination size
> [-Werror=stringop-truncation]
>
> This comes when the length of copy passed to strncpy is is equal to
> destination size, which could potentially lead to buffer overflow.
>
> There is a need to mitigate this potential issue by limiting the size of
> destination by 1 and explicitly terminate the destination with NULL.
>
> Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/lib/api/fs/fs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> index 11b3885e833e..027b18f7ed8c 100644
> --- a/tools/lib/api/fs/fs.c
> +++ b/tools/lib/api/fs/fs.c
> @@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
>         size_t name_len = strlen(fs->name);
>         /* name + "_PATH" + '\0' */
>         char upper_name[name_len + 5 + 1];
> +
>         memcpy(upper_name, fs->name, name_len);
>         mem_toupper(upper_name, name_len);
>         strcpy(&upper_name[name_len], "_PATH");
> @@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
>                 return false;
>
>         fs->found = true;
> -       strncpy(fs->path, override_path, sizeof(fs->path));
> +       strncpy(fs->path, override_path, sizeof(fs->path) - 1);
> +       fs->path[sizeof(fs->path) - 1] = '\0';
>         return true;
>  }
>
> --
> 2.17.1
>


-- 
Regards,
Andrey.

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

* Re: [PATCH] tools lib api fs: fix gcc9 compilation error
  2019-12-11  8:01 [PATCH] tools lib api fs: fix gcc9 compilation error Andrey Zhizhikin
  2019-12-17 21:21 ` Andrey Zhizhikin
@ 2019-12-18  3:10 ` Sergey Senozhatsky
  2019-12-18  4:40   ` Sergey Senozhatsky
  2019-12-18  7:29 ` Jiri Olsa
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Sergey Senozhatsky @ 2019-12-18  3:10 UTC (permalink / raw)
  To: Andrey Zhizhikin
  Cc: ast, daniel, kafai, songliubraving, yhs, andriin,
	sergey.senozhatsky, pmladek, wangkefeng.wang, linux-kernel,
	netdev, bpf, Andrey Zhizhikin, Arnaldo Carvalho de Melo,
	Jiri Olsa

On (19/12/11 08:01), Andrey Zhizhikin wrote:
[..]
> @@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
>  	size_t name_len = strlen(fs->name);
>  	/* name + "_PATH" + '\0' */
>  	char upper_name[name_len + 5 + 1];
> +
>  	memcpy(upper_name, fs->name, name_len);
>  	mem_toupper(upper_name, name_len);
>  	strcpy(&upper_name[name_len], "_PATH");
> @@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
>  		return false;
>  
>  	fs->found = true;
> -	strncpy(fs->path, override_path, sizeof(fs->path));
> +	strncpy(fs->path, override_path, sizeof(fs->path) - 1);
> +	fs->path[sizeof(fs->path) - 1] = '\0';

I think the trend these days is to prefer stracpy/strscpy over
strcpy/strlcpy/strncpy.

	-ss

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

* Re: [PATCH] tools lib api fs: fix gcc9 compilation error
  2019-12-18  3:10 ` Sergey Senozhatsky
@ 2019-12-18  4:40   ` Sergey Senozhatsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sergey Senozhatsky @ 2019-12-18  4:40 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Andrey Zhizhikin, ast, daniel, kafai, songliubraving, yhs,
	andriin, pmladek, wangkefeng.wang, linux-kernel, netdev, bpf,
	Andrey Zhizhikin, Arnaldo Carvalho de Melo, Jiri Olsa

On (19/12/18 12:10), Sergey Senozhatsky wrote:
> On (19/12/11 08:01), Andrey Zhizhikin wrote:
> [..]
> > @@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
> >  	size_t name_len = strlen(fs->name);
> >  	/* name + "_PATH" + '\0' */
> >  	char upper_name[name_len + 5 + 1];
> > +
> >  	memcpy(upper_name, fs->name, name_len);
> >  	mem_toupper(upper_name, name_len);
> >  	strcpy(&upper_name[name_len], "_PATH");
> > @@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
> >  		return false;
> >  
> >  	fs->found = true;
> > -	strncpy(fs->path, override_path, sizeof(fs->path));
> > +	strncpy(fs->path, override_path, sizeof(fs->path) - 1);
> > +	fs->path[sizeof(fs->path) - 1] = '\0';
> 
> I think the trend these days is to prefer stracpy/strscpy over
> strcpy/strlcpy/strncpy.

Scratch that. This is user-space, I should pay more attention.

	-ss

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

* Re: [PATCH] tools lib api fs: fix gcc9 compilation error
  2019-12-11  8:01 [PATCH] tools lib api fs: fix gcc9 compilation error Andrey Zhizhikin
  2019-12-17 21:21 ` Andrey Zhizhikin
  2019-12-18  3:10 ` Sergey Senozhatsky
@ 2019-12-18  7:29 ` Jiri Olsa
  2019-12-18 11:36 ` Petr Mladek
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2019-12-18  7:29 UTC (permalink / raw)
  To: Andrey Zhizhikin
  Cc: ast, daniel, kafai, songliubraving, yhs, andriin,
	sergey.senozhatsky, pmladek, wangkefeng.wang, linux-kernel,
	netdev, bpf, Andrey Zhizhikin, Arnaldo Carvalho de Melo,
	Jiri Olsa

On Wed, Dec 11, 2019 at 08:01:09AM +0000, Andrey Zhizhikin wrote:
> GCC9 introduced string hardening mechanisms, which exhibits the error
> during fs api compilation:
> 
> error: '__builtin_strncpy' specified bound 4096 equals destination size
> [-Werror=stringop-truncation]
> 
> This comes when the length of copy passed to strncpy is is equal to
> destination size, which could potentially lead to buffer overflow.
> 
> There is a need to mitigate this potential issue by limiting the size of
> destination by 1 and explicitly terminate the destination with NULL.
> 
> Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@kernel.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/lib/api/fs/fs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> index 11b3885e833e..027b18f7ed8c 100644
> --- a/tools/lib/api/fs/fs.c
> +++ b/tools/lib/api/fs/fs.c
> @@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
>  	size_t name_len = strlen(fs->name);
>  	/* name + "_PATH" + '\0' */
>  	char upper_name[name_len + 5 + 1];
> +
>  	memcpy(upper_name, fs->name, name_len);
>  	mem_toupper(upper_name, name_len);
>  	strcpy(&upper_name[name_len], "_PATH");
> @@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
>  		return false;
>  
>  	fs->found = true;
> -	strncpy(fs->path, override_path, sizeof(fs->path));
> +	strncpy(fs->path, override_path, sizeof(fs->path) - 1);
> +	fs->path[sizeof(fs->path) - 1] = '\0';
>  	return true;
>  }
>  
> -- 
> 2.17.1
> 


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

* Re: [PATCH] tools lib api fs: fix gcc9 compilation error
  2019-12-11  8:01 [PATCH] tools lib api fs: fix gcc9 compilation error Andrey Zhizhikin
                   ` (2 preceding siblings ...)
  2019-12-18  7:29 ` Jiri Olsa
@ 2019-12-18 11:36 ` Petr Mladek
  2019-12-18 14:33 ` Arnaldo Carvalho de Melo
  2020-01-10 17:53 ` [tip: perf/core] tools lib api fs: Fix gcc9 stringop-truncation " tip-bot2 for Andrey Zhizhikin
  5 siblings, 0 replies; 9+ messages in thread
From: Petr Mladek @ 2019-12-18 11:36 UTC (permalink / raw)
  To: Andrey Zhizhikin
  Cc: ast, daniel, kafai, songliubraving, yhs, andriin,
	sergey.senozhatsky, wangkefeng.wang, linux-kernel, netdev, bpf,
	Andrey Zhizhikin, Arnaldo Carvalho de Melo, Jiri Olsa

On Wed 2019-12-11 08:01:09, Andrey Zhizhikin wrote:
> GCC9 introduced string hardening mechanisms, which exhibits the error
> during fs api compilation:
> 
> error: '__builtin_strncpy' specified bound 4096 equals destination size
> [-Werror=stringop-truncation]
> 
> This comes when the length of copy passed to strncpy is is equal to
> destination size, which could potentially lead to buffer overflow.
> 
> There is a need to mitigate this potential issue by limiting the size of
> destination by 1 and explicitly terminate the destination with NULL.
> 
> Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@kernel.org>

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

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

* Re: [PATCH] tools lib api fs: fix gcc9 compilation error
  2019-12-11  8:01 [PATCH] tools lib api fs: fix gcc9 compilation error Andrey Zhizhikin
                   ` (3 preceding siblings ...)
  2019-12-18 11:36 ` Petr Mladek
@ 2019-12-18 14:33 ` Arnaldo Carvalho de Melo
  2019-12-18 17:03   ` Andrey Zhizhikin
  2020-01-10 17:53 ` [tip: perf/core] tools lib api fs: Fix gcc9 stringop-truncation " tip-bot2 for Andrey Zhizhikin
  5 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-12-18 14:33 UTC (permalink / raw)
  To: Andrey Zhizhikin
  Cc: ast, daniel, kafai, songliubraving, yhs, andriin,
	sergey.senozhatsky, pmladek, wangkefeng.wang, linux-kernel,
	netdev, bpf, Andrey Zhizhikin, Arnaldo Carvalho de Melo,
	Jiri Olsa

Em Wed, Dec 11, 2019 at 08:01:09AM +0000, Andrey Zhizhikin escreveu:
> GCC9 introduced string hardening mechanisms, which exhibits the error
> during fs api compilation:
> 
> error: '__builtin_strncpy' specified bound 4096 equals destination size
> [-Werror=stringop-truncation]
> 
> This comes when the length of copy passed to strncpy is is equal to
> destination size, which could potentially lead to buffer overflow.
> 
> There is a need to mitigate this potential issue by limiting the size of
> destination by 1 and explicitly terminate the destination with NULL.

Thanks, applied and collected the reviewed-by and acked-by provided,

- Arnaldo
 
> Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/lib/api/fs/fs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> index 11b3885e833e..027b18f7ed8c 100644
> --- a/tools/lib/api/fs/fs.c
> +++ b/tools/lib/api/fs/fs.c
> @@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
>  	size_t name_len = strlen(fs->name);
>  	/* name + "_PATH" + '\0' */
>  	char upper_name[name_len + 5 + 1];
> +
>  	memcpy(upper_name, fs->name, name_len);
>  	mem_toupper(upper_name, name_len);
>  	strcpy(&upper_name[name_len], "_PATH");
> @@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
>  		return false;
>  
>  	fs->found = true;
> -	strncpy(fs->path, override_path, sizeof(fs->path));
> +	strncpy(fs->path, override_path, sizeof(fs->path) - 1);
> +	fs->path[sizeof(fs->path) - 1] = '\0';
>  	return true;
>  }
>  
> -- 
> 2.17.1

-- 

- Arnaldo

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

* Re: [PATCH] tools lib api fs: fix gcc9 compilation error
  2019-12-18 14:33 ` Arnaldo Carvalho de Melo
@ 2019-12-18 17:03   ` Andrey Zhizhikin
  0 siblings, 0 replies; 9+ messages in thread
From: Andrey Zhizhikin @ 2019-12-18 17:03 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: ast, daniel, kafai, songliubraving, yhs, andriin,
	sergey.senozhatsky, pmladek, wangkefeng.wang, linux-kernel,
	netdev, bpf, Andrey Zhizhikin, Arnaldo Carvalho de Melo,
	Jiri Olsa

On Wed, Dec 18, 2019 at 3:33 PM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
>
> Em Wed, Dec 11, 2019 at 08:01:09AM +0000, Andrey Zhizhikin escreveu:
> > GCC9 introduced string hardening mechanisms, which exhibits the error
> > during fs api compilation:
> >
> > error: '__builtin_strncpy' specified bound 4096 equals destination size
> > [-Werror=stringop-truncation]
> >
> > This comes when the length of copy passed to strncpy is is equal to
> > destination size, which could potentially lead to buffer overflow.
> >
> > There is a need to mitigate this potential issue by limiting the size of
> > destination by 1 and explicitly terminate the destination with NULL.
>
> Thanks, applied and collected the reviewed-by and acked-by provided,

Thanks a lot for review and collecting this patch!

>
> - Arnaldo
>
> > Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/lib/api/fs/fs.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> > index 11b3885e833e..027b18f7ed8c 100644
> > --- a/tools/lib/api/fs/fs.c
> > +++ b/tools/lib/api/fs/fs.c
> > @@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
> >       size_t name_len = strlen(fs->name);
> >       /* name + "_PATH" + '\0' */
> >       char upper_name[name_len + 5 + 1];
> > +
> >       memcpy(upper_name, fs->name, name_len);
> >       mem_toupper(upper_name, name_len);
> >       strcpy(&upper_name[name_len], "_PATH");
> > @@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
> >               return false;
> >
> >       fs->found = true;
> > -     strncpy(fs->path, override_path, sizeof(fs->path));
> > +     strncpy(fs->path, override_path, sizeof(fs->path) - 1);
> > +     fs->path[sizeof(fs->path) - 1] = '\0';
> >       return true;
> >  }
> >
> > --
> > 2.17.1
>
> --
>
> - Arnaldo

-- 
Regards,
Andrey.

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

* [tip: perf/core] tools lib api fs: Fix gcc9 stringop-truncation compilation error
  2019-12-11  8:01 [PATCH] tools lib api fs: fix gcc9 compilation error Andrey Zhizhikin
                   ` (4 preceding siblings ...)
  2019-12-18 14:33 ` Arnaldo Carvalho de Melo
@ 2020-01-10 17:53 ` " tip-bot2 for Andrey Zhizhikin
  5 siblings, 0 replies; 9+ messages in thread
From: tip-bot2 for Andrey Zhizhikin @ 2020-01-10 17:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Andrey Zhizhikin, Petr Mladek, Jiri Olsa, Alexei Starovoitov,
	Andrii Nakryiko, Daniel Borkmann, Kefeng Wang, Martin KaFai Lau,
	Sergey Senozhatsky, Song Liu, Yonghong Song, bpf, netdev,
	Arnaldo Carvalho de Melo, x86, LKML

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     6794200fa3c9c3e6759dae099145f23e4310f4f7
Gitweb:        https://git.kernel.org/tip/6794200fa3c9c3e6759dae099145f23e4310f4f7
Author:        Andrey Zhizhikin <andrey.z@gmail.com>
AuthorDate:    Wed, 11 Dec 2019 08:01:09 
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Mon, 06 Jan 2020 11:46:09 -03:00

tools lib api fs: Fix gcc9 stringop-truncation compilation error

GCC9 introduced string hardening mechanisms, which exhibits the error
during fs api compilation:

error: '__builtin_strncpy' specified bound 4096 equals destination size
[-Werror=stringop-truncation]

This comes when the length of copy passed to strncpy is is equal to
destination size, which could potentially lead to buffer overflow.

There is a need to mitigate this potential issue by limiting the size of
destination by 1 and explicitly terminate the destination with NULL.

Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: http://lore.kernel.org/lkml/20191211080109.18765-1-andrey.zhizhikin@leica-geosystems.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 11b3885..027b18f 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
 	size_t name_len = strlen(fs->name);
 	/* name + "_PATH" + '\0' */
 	char upper_name[name_len + 5 + 1];
+
 	memcpy(upper_name, fs->name, name_len);
 	mem_toupper(upper_name, name_len);
 	strcpy(&upper_name[name_len], "_PATH");
@@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
 		return false;
 
 	fs->found = true;
-	strncpy(fs->path, override_path, sizeof(fs->path));
+	strncpy(fs->path, override_path, sizeof(fs->path) - 1);
+	fs->path[sizeof(fs->path) - 1] = '\0';
 	return true;
 }
 

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

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11  8:01 [PATCH] tools lib api fs: fix gcc9 compilation error Andrey Zhizhikin
2019-12-17 21:21 ` Andrey Zhizhikin
2019-12-18  3:10 ` Sergey Senozhatsky
2019-12-18  4:40   ` Sergey Senozhatsky
2019-12-18  7:29 ` Jiri Olsa
2019-12-18 11:36 ` Petr Mladek
2019-12-18 14:33 ` Arnaldo Carvalho de Melo
2019-12-18 17:03   ` Andrey Zhizhikin
2020-01-10 17:53 ` [tip: perf/core] tools lib api fs: Fix gcc9 stringop-truncation " tip-bot2 for Andrey Zhizhikin

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git