From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Thomas Rast <trast@student.ethz.ch>,
Franck Bui-Huu <vagabon.xyz@gmail.com>,
Erik Faye-Lund <kusmabite@gmail.com>,
git@vger.kernel.org, j6t@kdbg.org, rene.scharfe@lsrfire.ath.cx
Subject: Re: [PATCH v4 3/3] upload-archive: use start_command instead of fork
Date: Tue, 15 Nov 2011 14:18:32 -0500 [thread overview]
Message-ID: <20111115191832.GA16030@sigill.intra.peff.net> (raw)
In-Reply-To: <7vobwdus7w.fsf@alter.siamese.dyndns.org>
On Tue, Nov 15, 2011 at 10:59:47AM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > Junio, this bug is in 1.7.8-rc*. Do you want the one-liner fix for the
> > release, or the nicer fix?
>
> Let's just do "static" for now, if we know the array is large enough.
OK, here it is.
I think it's correct, but I couldn't reproduce the valgrind failure
here. Thomas, can you double check that this also solves your problem?
-Peff
-- >8 --
Subject: [PATCH] upload-archive: don't return pointers to stack buffer
The prepare_argv function uses an internal stack-allocated
buffer to create the argv array that will be used to run
git-archive. Prior to c09cd77e, this was OK, as the
function passed the argv array to write_archive itself, and
the stack buffer was valid during its use.
Since c09cd77e, however, the function returns an argv array
with pointers pointing into the stack buffer. The calling
function then passes the result to start_command, which
tries to execve using pointers to a now-invalid buffer.
Fix it by making the buffer static, which is a quick and
simple fix, and works because we only run this function once
per process.
Credit for finding the bug and most of the analysis goes to
Thomas Rast.
Signed-off-by: Jeff King <peff@peff.net>
---
builtin/upload-archive.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index c57e8bd..f47c0f0 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -22,7 +22,8 @@
static void prepare_argv(const char **sent_argv, const char **argv)
{
const char *arg_cmd = "argument ";
- char *p, buf[4096];
+ char *p;
+ static char buf[4096];
int sent_argc;
int len;
--
1.7.7.3.8.g38efa
next prev parent reply other threads:[~2011-11-15 19:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-24 16:02 [PATCH v4 0/3] port upload-archive to Windows Erik Faye-Lund
2011-10-24 16:02 ` [PATCH v4 1/3] mingw: move poll out of sys-folder Erik Faye-Lund
2011-10-24 16:02 ` [PATCH v4 2/3] compat/win32/poll.c: upgrade from upstream Erik Faye-Lund
2011-10-24 16:02 ` [PATCH v4 3/3] upload-archive: use start_command instead of fork Erik Faye-Lund
2011-10-24 22:39 ` Jeff King
2011-11-15 10:22 ` Thomas Rast
2011-11-15 10:28 ` Jeff King
2011-11-15 12:11 ` Thomas Rast
2011-11-15 17:37 ` Jeff King
2011-11-15 17:44 ` Erik Faye-Lund
2011-11-15 18:18 ` Jeff King
2011-11-15 18:59 ` Junio C Hamano
2011-11-15 19:18 ` Jeff King [this message]
2011-11-15 19:46 ` [PATCH 1/2] upload-archive: drop extra argument to prepare_argv Jeff King
2011-11-15 19:49 ` [PATCH] upload-archive: use argv_array for sent parameters Jeff King
2011-11-15 21:30 ` Jeff King
2011-11-15 18:53 ` [PATCH v4 3/3] upload-archive: use start_command instead of fork Andreas Schwab
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=20111115191832.GA16030@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=kusmabite@gmail.com \
--cc=rene.scharfe@lsrfire.ath.cx \
--cc=trast@student.ethz.ch \
--cc=vagabon.xyz@gmail.com \
/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).