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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090409221722.6439ba11.akpm@linux-foundation.org>
Date:	Thu, 9 Apr 2009 22:17:22 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Andrew Patterson <andrew.patterson@...com>
Cc:	"Mike Miller (OS Dev)" <mikem@...rdog.cca.cpqcorp.net>,
	Jens Axboe <jens.axboe@...cle.com>,
	LKML <linux-kernel@...r.kernel.org>,
	LKML-SCSI <linux-scsi@...r.kernel.org>, mike.miller@...com
Subject: Re: [PATCH 1/1] cciss: resubmit export uid, model, vendor, rev to
 sysfs

On Fri, 10 Apr 2009 05:08:54 +0000 Andrew Patterson <andrew.patterson@...com> wrote:

> > > +	char model[MODEL_LEN + 1];
> > > ...
> > > +		return snprintf(buf, MODEL_LEN + 2, "%s\n", drv->model);
> > 
> > Isn't the buffer sizing wrong here?  Should be MODEL_LEN+1.
> > 
> 
> Don't we need space for the '\0' and the '\n'?

The second arg to snprintf() tells snprintf() how large the buffer is. 
That buffer should be sized to allow room for the trailing \0.

So if MODEL_LEN represents the maximum number of characters in a string
then you want:

	char model[MODEL_LEN + 2];	/* Room for the \n and the \0 */
	...
	return snprintf(buf, sizeof(model), "%s\n", drv->model);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ