From: Rob Landley <rob@landley.net>
To: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH] doc: avoid strncpy in accounting tool
Date: Sat, 08 Jun 2013 13:50:06 -0500 [thread overview]
Message-ID: <1370717406.2776.83@driftwood> (raw)
In-Reply-To: <20130606024930.GA24279@www.outflux.net> (from keescook@chromium.org on Wed Jun 5 21:49:30 2013)
On 06/05/2013 09:49:30 PM, Kees Cook wrote:
> Avoid strncpy anti-pattern. Use strdup() instead, as already done for
> the logfile optarg.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> Fix for -mm clean-up-scary-strncpydst-src-strlensrc-uses-fix.patch
> ---
> Documentation/accounting/getdelays.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/accounting/getdelays.c
> b/Documentation/accounting/getdelays.c
> index f8ebcde..1db89d3 100644
> --- a/Documentation/accounting/getdelays.c
> +++ b/Documentation/accounting/getdelays.c
> @@ -272,7 +272,7 @@ int main(int argc, char *argv[])
> char *logfile = NULL;
> int loop = 0;
> int containerset = 0;
> - char containerpath[1024];
> + char *containerpath = NULL;
> int cfd = 0;
> int forking = 0;
> sigset_t sigset;
> @@ -299,7 +299,7 @@ int main(int argc, char *argv[])
> break;
> case 'C':
> containerset = 1;
> - strncpy(containerpath, optarg, strlen(optarg) +
> 1);
> + containerpath = strdup(optarg);
*boggle* That an elaborate way of doing a standard strcpy(), isn't it?
(Assuming free() being done by exit() is ok, and that somebody's going
to be modifying this string so just keeping the pointer to optarg might
make ps look weird...)
Acked-by: Rob Landley <rob@landley.net>
if Andrew hasn't grabbed it already (I'm days behind on email) please
send through trivial@kernel.org.
Rob
next prev parent reply other threads:[~2013-06-09 1:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 2:49 [PATCH] doc: avoid strncpy in accounting tool Kees Cook
2013-06-06 16:52 ` Andreas Schwab
2013-06-08 18:50 ` Rob Landley [this message]
2013-06-10 21:21 ` Andrew Morton
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=1370717406.2776.83@driftwood \
--to=rob@landley.net \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox