From: Randy Dunlap <rdunlap@infradead.org>
To: Pavel Machek <pavel@ucw.cz>
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,
trivial@kernel.org
Subject: Re: [PATCHv3] Documentation: laptops: freefall.c: simplify to avoid null-termination problems
Date: Mon, 28 Jul 2014 17:17:54 -0700 [thread overview]
Message-ID: <53D6E832.7020306@infradead.org> (raw)
In-Reply-To: <20140728111351.GB17250@amd.pavel.ucw.cz>
On 07/28/14 04:13, Pavel Machek wrote:
>
> Copying to local variable is actually not neccessary, if all we need
> to do is snprintf(). This also removes problem where devname could be
> missing zero termination.
>
> Reported-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> Signed-off-by: Pavel Machek <pavel@ucw.cz>
Applied. Thanks.
>
> diff --git a/Documentation/laptops/freefall.c b/Documentation/laptops/freefall.c
> index aab2ff0..5e44b20 100644
> --- a/Documentation/laptops/freefall.c
> +++ b/Documentation/laptops/freefall.c
> @@ -29,15 +29,12 @@ static const char app_name[] = "FREE FALL";
>
> static int set_unload_heads_path(char *device)
> {
> - char devname[64];
> -
> 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);
>
> snprintf(unload_heads_path, sizeof(unload_heads_path) - 1,
> - "/sys/block/%s/device/unload_heads", devname);
> + "/sys/block/%s/device/unload_heads", device+5);
> return 0;
> }
>
>
>
>
--
~Randy
prev parent reply other threads:[~2014-07-29 0:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-27 14:40 [PATCH] Documentation: laptops: freefall.c: Cleaning up missing null-terminate in conjunction with strncpy Rickard Strandqvist
2014-07-27 19:29 ` Pavel Machek
2014-07-27 23:03 ` Randy Dunlap
2014-07-28 10:20 ` Pavel Machek
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 [this message]
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=53D6E832.7020306@infradead.org \
--to=rdunlap@infradead.org \
--cc=jkosina@suse.cz \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=sw@weilnetz.de \
--cc=trivial@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.