From: Pavel Machek <pavel@ucw.cz>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: "Rickard Strandqvist" <rickard_strandqvist@spectrumdigital.se>,
"Pali Rohár" <pali.rohar@gmail.com>,
"Stefan Weil" <sw@weilnetz.de>, "Jiri Kosina" <jkosina@suse.cz>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Documentation: laptops: freefall.c: Cleaning up missing null-terminate in conjunction with strncpy
Date: Mon, 28 Jul 2014 12:20:40 +0200 [thread overview]
Message-ID: <20140728102040.GA16495@amd.pavel.ucw.cz> (raw)
In-Reply-To: <53D58550.6040205@infradead.org>
On Sun 2014-07-27 16:03:44, Randy Dunlap wrote:
> On 07/27/14 07:40, Rickard Strandqvist wrote:
> > Added a guaranteed null-terminate after call to strncpy.
> >
> > Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> > ---
> > Documentation/laptops/freefall.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/laptops/freefall.c b/Documentation/laptops/freefall.c
> > index aab2ff0..113d004 100644
> > --- a/Documentation/laptops/freefall.c
> > +++ b/Documentation/laptops/freefall.c
> > @@ -33,8 +33,10 @@ static int set_unload_heads_path(char *device)
> >
> > if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0)
> > return -EINVAL;
> > - strncpy(devname, device + 5, sizeof(devname) - 1);
> > - strncpy(device_path, device, sizeof(device_path) - 1);
>
> Maybe I am overlooking something here, but what was wrong with
> the - 1 (2 times) above? and then just add the 2 lines below that set the
> last byte to '\0'?
Actually device_path is static, so it will be zero-initialized and
explicit set is not neccessary AFAICT.
(devname is auto -> needs explicit set).
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2014-07-28 10:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-27 14:40 Rickard Strandqvist
2014-07-27 19:29 ` Pavel Machek
2014-07-27 23:03 ` Randy Dunlap
2014-07-28 10:20 ` Pavel Machek [this message]
2014-07-28 11:10 ` [PATCHv2] Documentation: laptops: freefall.c: Fix missing null-termination Pavel Machek
2014-07-28 11:13 ` [PATCHv3] Documentation: laptops: freefall.c: simplify to avoid null-termination problems Pavel Machek
2014-07-29 0:17 ` Randy Dunlap
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=20140728102040.GA16495@amd.pavel.ucw.cz \
--to=pavel@ucw.cz \
--cc=jkosina@suse.cz \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pali.rohar@gmail.com \
--cc=rdunlap@infradead.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=sw@weilnetz.de \
/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
all inboxes | Powered by JetHome®