From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Paolo Bonzini <bonzini@gnu.org>, git@vger.kernel.org
Subject: Re: [PATCH 1/4] git-commit: support variable number of hook arguments
Date: Mon, 04 Feb 2008 19:09:34 -0800 [thread overview]
Message-ID: <7vejbsgkup.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: alpine.LSU.1.00.0802041637460.7372@racer.site
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Hi,
>
> On Mon, 21 Jan 2008, Paolo Bonzini wrote:
>
>> +static int run_hook(const char *index_file, const char *name, ...)
>> +{
>> + struct child_process hook;
>> + const char *argv[10], *env[2];
>> + char index[PATH_MAX];
>> + va_list args;
>> + int i;
>> +
>> + va_start(args, name);
>> + argv[0] = git_path("hooks/%s", name);
>> + i = 0;
>> + do {
>
> Here, an
>
> if (++i >= ARRAY_SIZE(argv))
> die ("run_hook(): too many arguments");
>
> is missing. Even nicer, you could have
>
> int argc = 1;
> char **argv = malloc(sizeof(*argv) * 2);
>
> and
>
> if (++i >= argc)
> argc = ALLOC_GROW(argv, i + 1, argc);
The sanity check to make sure we do not feed too many is
definitely needed. For this application I think ALLOC_GROW() is
overkill, as we do not pass unbound number of arguments to the
hook.
next prev parent reply other threads:[~2008-02-05 3:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-21 14:27 [PATCH] git-commit: add a prepare-commit-msg hook Paolo Bonzini
2008-01-21 14:02 ` [PATCH 1/4] git-commit: support variable number of hook arguments Paolo Bonzini
2008-02-04 16:43 ` Johannes Schindelin
2008-02-05 3:09 ` Junio C Hamano [this message]
2008-01-21 14:06 ` [PATCH 2/4] git-commit: set GIT_EDITOR=: if editor will not be launched Paolo Bonzini
2008-01-21 14:27 ` [PATCH 4/4] git-commit: add a prepare-commit-msg hook Paolo Bonzini
2008-02-05 3:08 ` Junio C Hamano
2008-01-21 14:33 ` [PATCH 3/4] git-commit: Refactor creation of log message Paolo Bonzini
2008-02-04 16:48 ` Johannes Schindelin
2008-02-04 17:14 ` Paolo Bonzini
2008-02-05 1:39 ` Junio C Hamano
2008-02-05 4:07 ` Junio C Hamano
2008-02-05 6:07 ` Paolo Bonzini
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=7vejbsgkup.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=bonzini@gnu.org \
--cc=git@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;
as well as URLs for NNTP newsgroup(s).