Re: [PATCH 1/1] cciss: resubmit export uid, model, vendor, rev to sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 10 Apr 2009 05:08:54 +0000 Andrew Patterson <andrew.patterson@xxxxxx> 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-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux