LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] tracing: prefer strlcpy to strncpy
@ 2018-05-29  6:03 Nick Desaulniers
  2018-05-30  1:55 ` Nick Desaulniers
  2018-06-04 18:06 ` Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Desaulniers @ 2018-05-29  6:03 UTC (permalink / raw)
  To: rostedt, mingo; +Cc: Nick Desaulniers, linux-kernel

Fixes a stringop-truncation warning from gcc-8.

Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index b9061ed..b53a6c0 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
 	else if (system)
 		snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event);
 	else
-		strncpy(err, var, MAX_FILTER_STR_VAL);
+		strlcpy(err, var, MAX_FILTER_STR_VAL);
 
 	hist_err(str, err);
 }
-- 
2.7.4

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

* Re: [PATCH] tracing: prefer strlcpy to strncpy
  2018-05-29  6:03 [PATCH] tracing: prefer strlcpy to strncpy Nick Desaulniers
@ 2018-05-30  1:55 ` Nick Desaulniers
  2018-06-04 18:10   ` Steven Rostedt
  2018-06-04 18:06 ` Steven Rostedt
  1 sibling, 1 reply; 4+ messages in thread
From: Nick Desaulniers @ 2018-05-30  1:55 UTC (permalink / raw)
  To: Steven Rostedt (VMware), Ingo Molnar
  Cc: Nick Desaulniers, Linux Kernel Mailing List, ebiggers

On Mon, May 28, 2018 at 11:03 PM, Nick Desaulniers
<nick.desaulniers@gmail.com> wrote:
> Fixes a stringop-truncation warning from gcc-8.
>
> Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
> ---
>  kernel/trace/trace_events_hist.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index b9061ed..b53a6c0 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
>         else if (system)
>                 snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event);
>         else
> -               strncpy(err, var, MAX_FILTER_STR_VAL);
> +               strlcpy(err, var, MAX_FILTER_STR_VAL);
>
>         hist_err(str, err);
>  }
> --
> 2.7.4
>

Eric points out this wont initialize the rest of err with zeros.

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

* Re: [PATCH] tracing: prefer strlcpy to strncpy
  2018-05-29  6:03 [PATCH] tracing: prefer strlcpy to strncpy Nick Desaulniers
  2018-05-30  1:55 ` Nick Desaulniers
@ 2018-06-04 18:06 ` Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2018-06-04 18:06 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: mingo, linux-kernel, trivial

On Mon, 28 May 2018 23:03:38 -0700
Nick Desaulniers <nick.desaulniers@gmail.com> wrote:

> Fixes a stringop-truncation warning from gcc-8.
> 
> Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

> ---
>  kernel/trace/trace_events_hist.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index b9061ed..b53a6c0 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
>  	else if (system)
>  		snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event);
>  	else
> -		strncpy(err, var, MAX_FILTER_STR_VAL);
> +		strlcpy(err, var, MAX_FILTER_STR_VAL);
>  
>  	hist_err(str, err);
>  }

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

* Re: [PATCH] tracing: prefer strlcpy to strncpy
  2018-05-30  1:55 ` Nick Desaulniers
@ 2018-06-04 18:10   ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2018-06-04 18:10 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: Ingo Molnar, Linux Kernel Mailing List, ebiggers

On Tue, 29 May 2018 18:55:23 -0700
Nick Desaulniers <nick.desaulniers@gmail.com> wrote:

> On Mon, May 28, 2018 at 11:03 PM, Nick Desaulniers
> <nick.desaulniers@gmail.com> wrote:
> > Fixes a stringop-truncation warning from gcc-8.
> >
> > Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
> > ---
> >  kernel/trace/trace_events_hist.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> > index b9061ed..b53a6c0 100644
> > --- a/kernel/trace/trace_events_hist.c
> > +++ b/kernel/trace/trace_events_hist.c
> > @@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
> >         else if (system)
> >                 snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event);
> >         else
> > -               strncpy(err, var, MAX_FILTER_STR_VAL);
> > +               strlcpy(err, var, MAX_FILTER_STR_VAL);
> >
> >         hist_err(str, err);
> >  }
> > --
> > 2.7.4
> >  
> 
> Eric points out this wont initialize the rest of err with zeros.

And why do we care?

-- Steve

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

end of thread, other threads:[~2018-06-04 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29  6:03 [PATCH] tracing: prefer strlcpy to strncpy Nick Desaulniers
2018-05-30  1:55 ` Nick Desaulniers
2018-06-04 18:10   ` Steven Rostedt
2018-06-04 18:06 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).