From: Johannes Sixt <j.sixt@viscovery.net>
To: unlisted-recipients:; (no To-header on input)
Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org
Subject: [PATCH] Fix invocation of external git commands with arguments with spaces.
Date: Wed, 10 Oct 2007 09:00:12 +0200 [thread overview]
Message-ID: <470C787C.6090900@viscovery.net> (raw)
In-Reply-To: <470C6E58.3080208@viscovery.net>
If an external git command (not a shell script) was invoked with arguments
that contain spaces, these arguments would be split into separate
arguments. They must be quoted. This also affected installations where
$prefix contained a space, as in "C:\Program Files\GIT". Both errors can
be triggered by invoking
git hash-object "a b"
where "a b" is an existing file.
---
Johannes Sixt schrieb:
> BTW, I think the fix is incomplete anyway: We quote only argv[0], but
> actually all of argv should be quoted. Will test.
Here is the proper fix.
Yes, this leaks memory on the error path. We can clean that up later...
-- Hannes
compat/mingw.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 8bb0dba..2554f19 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -405,7 +405,12 @@ void mingw_execve()
{
/* check if git_command is a shell script */
if (!try_shell_exec(cmd, argv, env)) {
- int ret = spawnve(_P_WAIT, cmd, argv, env);
+ const char **qargv;
+ int n;
+ for (n = 0; argv[n];) n++;
+ qargv = xmalloc((n+1)*sizeof(char*));
+ quote_argv(qargv, argv);
+ int ret = spawnve(_P_WAIT, cmd, qargv, env);
if (ret != -1)
exit(ret);
}
--
1.5.3.717.g01fc-dirty
prev parent reply other threads:[~2007-10-10 7:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-08 11:06 Merge problems with git-mingw Peter Karlsson
2007-10-08 12:00 ` Lars Hjemli
2007-10-08 12:33 ` Peter Karlsson
2007-10-08 13:10 ` Lars Hjemli
2007-10-08 14:56 ` Peter Karlsson
2007-10-08 19:59 ` Lars Hjemli
2007-10-09 6:10 ` Johannes Sixt
2007-10-09 7:06 ` Peter Karlsson
2007-10-09 7:36 ` Johannes Sixt
2007-10-09 8:56 ` Peter Karlsson
2007-10-09 9:03 ` Johannes Sixt
2007-10-09 16:33 ` Steffen Prohaska
2007-10-09 17:03 ` Johannes Sixt
2007-10-09 18:09 ` Linus Torvalds
2007-10-09 21:39 ` [PATCH] exec_git_cmd: fix executing commands if path contains spaces Steffen Prohaska
2007-10-10 6:16 ` Johannes Sixt
2007-10-10 7:00 ` Johannes Sixt [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=470C787C.6090900@viscovery.net \
--to=j.sixt@viscovery.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=prohaska@zib.de \
/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).