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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 12 Oct 2021 11:05:57 +0000
From:   <Viktor.Rosendahl@....de>
To:     <rostedt@...dmis.org>, <davidcomponentone@...il.com>
CC:     <vulab@...as.ac.cn>, <colin.king@...onical.com>,
        <linux-kernel@...r.kernel.org>, <zealci@....com.cn>
Subject: Re: [PATCH] Fix application of sizeof to pointer

On Mon, 2021-10-11 at 23:06 -0400, Steven Rostedt wrote:
> On Tue, 12 Oct 2021 10:54:24 +0800
> davidcomponentone@...il.com wrote:
> 
> > From: David Yang <davidcomponentone@...il.com>
> > 
> > The coccinelle check report:
> > "./tools/tracing/latency/latency-collector.c:1541:10-16:
> > ERROR: application of sizeof to pointer"
> > Using the "strlen" to fix it.
> > 
> > Reported-by: Zeal Robot <zealci@....com.cn>
> > Signed-off-by: David Yang <davidcomponentone@...il.com>
> > ---
> >  tools/tracing/latency/latency-collector.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/tracing/latency/latency-collector.c
> > b/tools/tracing/latency/latency-collector.c
> > index 3a2e6bb781a8..b131007e6c70 100644
> > --- a/tools/tracing/latency/latency-collector.c
> > +++ b/tools/tracing/latency/latency-collector.c
> > @@ -1538,7 +1538,7 @@ static void tracing_loop(void)
> >  				mutex_lock(&print_mtx);
> >  				check_signals();
> >  				write_or_die(fd_stdout, queue_full_warning,
> > -					     sizeof(queue_full_warning));
> > +					     strlen(queue_full_warning) + 1);
> 
> Really, the +1, although would match if queue_full_warning was an
> array, but in this use case, there's no reason to pass the nul
> character to the write.

I agree that the +1 should not be there because the null character would end up
in the output; write will not ignore it. It could be confusing if the output
would be be processed by another program.

best regards,

Viktor

> 
> -- Steve
> 
> 
> >  				mutex_unlock(&print_mtx);
> >  			}
> >  			modified--;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ