From: Andrew Morton <akpm@linux-foundation.org>
To: Andrew Patterson <andrew.patterson@hp.com>
Cc: "Mike Miller (OS Dev)" <mikem@beardog.cca.cpqcorp.net>,
Jens Axboe <jens.axboe@oracle.com>,
LKML <linux-kernel@vger.kernel.org>,
LKML-SCSI <linux-scsi@vger.kernel.org>,
mike.miller@hp.com
Subject: Re: [PATCH 1/1] cciss: resubmit export uid, model, vendor, rev to sysfs
Date: Thu, 9 Apr 2009 22:17:22 -0700 [thread overview]
Message-ID: <20090409221722.6439ba11.akpm@linux-foundation.org> (raw)
In-Reply-To: <1239340134.19984.276.camel@grinch>
On Fri, 10 Apr 2009 05:08:54 +0000 Andrew Patterson <andrew.patterson@hp.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);
next prev parent reply other threads:[~2009-04-10 5:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 18:04 [PATCH 1/1] cciss: resubmit export uid, model, vendor, rev to sysfs Mike Miller (OS Dev)
2009-04-08 6:19 ` Jens Axboe
2009-04-08 8:13 ` Jens Axboe
2009-04-08 14:53 ` Mike Miller (OS Dev)
2009-04-08 12:26 ` Kay Sievers
2009-04-08 16:24 ` Andrew Patterson
2009-04-08 16:34 ` Kay Sievers
[not found] ` <1239258160.19984.217.camel@grinch>
[not found] ` <ac3eb2510904090719n730dededp54b25390a9087a79@mail.gmail.com>
[not found] ` <1239296221.19984.218.camel@grinch>
[not found] ` <ac3eb2510904091005q13e5b5a1j3907de22ad3df70c@mail.gmail.com>
2009-04-09 18:07 ` Andrew Patterson
2009-04-09 18:12 ` Kay Sievers
2009-04-10 4:52 ` Andrew Morton
2009-04-10 5:08 ` Andrew Patterson
2009-04-10 5:17 ` Andrew Morton [this message]
2009-04-10 17:19 ` Andrew Patterson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090409221722.6439ba11.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andrew.patterson@hp.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mike.miller@hp.com \
--cc=mikem@beardog.cca.cpqcorp.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox