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] [thread-next>] [day] [month] [year] [list]
Message-ID: <YzRLzkltH1nwroNc@octinomon>
Date:   Wed, 28 Sep 2022 14:27:42 +0100
From:   Jules Irenge <jbi.octave@...il.com>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     abbotti@....co.uk, hsweeten@...ionengravers.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/7] comedi: Convert snprintf() to scnprintf()

On Tue, Sep 27, 2022 at 08:06:55AM +0200, Greg KH wrote:
> On Mon, Sep 26, 2022 at 07:37:37PM +0100, Jules Irenge wrote:
> > Coccinnelle reports a warning
> > Warning: Use scnprintf or sprintf
> > Adding to that, there has been a slow migration from snprintf to scnprintf.
> > This LWN article explains the rationale for this change
> > https: //lwn.net/Articles/69419/
> > Ie. snprintf() returns what *would* be the resulting length,
> > while scnprintf() returns the actual length.
> > 
> > Signed-off-by: Jules Irenge <jbi.octave@...il.com>
> > ---
> >  drivers/comedi/comedi_fops.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
> > index 55a0cae04b8d..e8a0142d5894 100644
> > --- a/drivers/comedi/comedi_fops.c
> > +++ b/drivers/comedi/comedi_fops.c
> > @@ -396,7 +396,7 @@ static ssize_t max_read_buffer_kb_show(struct device *csdev,
> >  	mutex_unlock(&dev->mutex);
> >  
> >  	comedi_dev_put(dev);
> > -	return snprintf(buf, PAGE_SIZE, "%u\n", size);
> > +	return scnprintf(buf, PAGE_SIZE, "%u\n", size);
> 
> Ick, no, you should use sysfs_emit() if you really want to change these
> functions to "do the right thing".
> 
> thanks,
> 
> greg k-h

Thanks for feedback. 

I just sent a different version.

I will appreciate any more feedback.

Thanks,

Jules

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ