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]
Message-ID: <46a600465f08edbda7d413f6dd0b1b1edd57cfa4.camel@perches.com>
Date:   Wed, 28 Sep 2022 16:04:07 -0700
From:   Joe Perches <joe@...ches.com>
To:     Alexandra Winter <wintera@...ux.ibm.com>,
        Jules Irenge <jbi.octave@...il.com>, borntraeger@...ux.ibm.com
Cc:     svens@...ux.ibm.com, linux-s390@...r.kernel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        agordeev@...ux.ibm.com
Subject: Re: [PATCH 3/7] s390/qeth: Convert snprintf() to scnprintf()

On Wed, 2022-09-28 at 10:24 +0200, Alexandra Winter wrote:
> On 27.09.22 16:27, Joe Perches wrote:
> > On Mon, 2022-09-26 at 19:42 +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.
> > []
> > > diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c
> > []
> > > @@ -500,9 +500,9 @@ static ssize_t qeth_hw_trap_show(struct device *dev,
> > >  	struct qeth_card *card = dev_get_drvdata(dev);
> > >  
> > >  	if (card->info.hwtrap)
> > > -		return snprintf(buf, 5, "arm\n");
> > > +		return scnprintf(buf, 5, "arm\n");
> > >  	else
> > > -		return snprintf(buf, 8, "disarm\n");
> > > +		return scnprintf(buf, 8, "disarm\n");
> > >  }
> > 
> > Use sysfs_emit instead.
> > 
> 
> Thank you Joe, that sounds like the best way to handle this. 
> I propose that I take this onto my ToDo list and test it in the s390 environment.
> I will add 
> Reported-by: Jules Irenge <jbi.octave@...il.com>
> Suggested-by: Joe Perches <joe@...ches.com>
> 

Thanks.

btw: I was careless when I wrote one section of the proposed patch.

In this patch block,

@@ -467,28 +478,31 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev,

The last line

+	return sysfs_emit_at(buf, len, "\n");

is not correct

It needs to be changed to:

	len += sysfs_emit_at(buf, len, "\n");

	return len;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ