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: <707865b7ccc9168177940cd4f63cf7cb9ead2d63.camel@perches.com>
Date:   Thu, 17 Sep 2020 08:28:12 -0700
From:   Joe Perches <joe@...ches.com>
To:     Xiongfeng Wang <wangxiongfeng2@...wei.com>,
        Borislav Petkov <bp@...en8.de>
Cc:     mchehab@...nel.org, tony.luck@...el.com,
        linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] EDAC/mc_sysfs: Add missing newlines when printing
 {max,dimm}_location

On Thu, 2020-09-17 at 19:38 +0800, Xiongfeng Wang wrote:
> On 2020/9/17 1:00, Borislav Petkov wrote:
> > On Mon, Sep 14, 2020 at 10:48:54AM +0800, Xiongfeng Wang wrote:
> > > @@ -813,15 +817,21 @@ static ssize_t mci_max_location_show(struct device *dev,
> > >  				     char *data)
> > >  {
> > >  	struct mem_ctl_info *mci = to_mci(dev);
> > > -	int i;
> > > +	int i, n;
> > >  	char *p = data;
> > > +	unsigned int len = PAGE_SIZE;
> > >  
> > >  	for (i = 0; i < mci->n_layers; i++) {
> > > -		p += sprintf(p, "%s %d ",
> > > +		n = snprintf(p, len, "%s %d ",
> > >  			     edac_layer_name[mci->layers[i].type],
> > >  			     mci->layers[i].size - 1);
> > > +		p += n;
> > > +		len -= n;
> > 
> > What happens if that subtraction causes len to wrap around and become a
> > huge positive unsigned integer?

If you're really concerned about wrapping, use scnprintf.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ