From: Jeff King <peff@peff.net>
To: Thomas Rast <trast@inf.ethz.ch>
Cc: git@vger.kernel.org, Steve Losh <steve@stevelosh.com>
Subject: Re: [PATCH] Support running an arbitrary git action through checkout
Date: Fri, 10 May 2013 19:00:17 +0200 [thread overview]
Message-ID: <20130510170016.GA29848@sigill.intra.peff.net> (raw)
In-Reply-To: <2d5cfb3be9487f607051cad3d5230434660307ba.1368198269.git.trast@inf.ethz.ch>
On Fri, May 10, 2013 at 05:06:07PM +0200, Thomas Rast wrote:
> + if (argc > 1 && !prefixcmp(argv[1], "--")) {
> + const char *subcommand = argv[1] + 2;
> + struct cmdnames main_cmds, other_cmds;
> +
> + memset(&main_cmds, 0, sizeof(main_cmds));
> + memset(&other_cmds, 0, sizeof(other_cmds));
> +
> + load_command_list("git-", &main_cmds, &other_cmds);
> +
> + if (is_in_cmdlist(&main_cmds, subcommand) ||
> + is_in_cmdlist(&other_cmds, subcommand)) {
> + const char **args = xmalloc((argc) * sizeof(char*));
> + args[0] = subcommand;
> + memcpy(args+1, argv+2, argc*sizeof(char*));
> + args[argc] = NULL;
Doesn't this memcpy overflow args, since it is only argc slots long? I
think you want to copy only (argc-1) slots, since you are omitting both
argv[0] as well as the "--subcommand" argument in argv[1]. You can also
drop the setting of NULL, as you will copy the original NULL as the last
item in your memcpy.
Other than that, the patch looks brilliant. :)
-Peff
prev parent reply other threads:[~2013-05-10 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-10 15:06 [PATCH] Support running an arbitrary git action through checkout Thomas Rast
2013-05-10 15:52 ` Junio C Hamano
2013-05-10 16:35 ` Ramkumar Ramachandra
2013-05-10 17:00 ` Jeff King [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=20130510170016.GA29848@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=steve@stevelosh.com \
--cc=trast@inf.ethz.ch \
/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;
as well as URLs for NNTP newsgroup(s).