From: Johan Herland <johan@herland.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH] builtin-config: Fix crash when using "-f <relative path>" from non-root dir
Date: Tue, 26 Jan 2010 16:02:16 +0100 [thread overview]
Message-ID: <201001261602.16876.johan@herland.net> (raw)
When your current directory is not at the root of the working tree, and you
use the "-f" option with a relative path, the current code segfaults since
argv has already been parsed, and argv[2] is now is a NULL pointer.
This patch replaces the incorrect argv[2] with the variable holding the
given config file name.
The bug was introduced by d64ec16... (git config: reorganize to use parseopt).
Signed-off-by: Johan Herland <johan@herland.net>
---
This is probably v1.7.0 material, and maybe even suitable for 'maint'.
AFAICS, d64ec16... has been with us since before v1.6.3-rc0.
...Johan
builtin-config.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-config.c b/builtin-config.c
index 2e3ef91..4bc46b1 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -358,7 +358,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
if (!is_absolute_path(given_config_file) && prefix)
config_exclusive_filename = prefix_filename(prefix,
strlen(prefix),
- argv[2]);
+ given_config_file);
else
config_exclusive_filename = given_config_file;
}
--
1.6.6.rc2.5.g49666
--
Johan Herland, <johan@herland.net>
www.herland.net
next reply other threads:[~2010-01-26 15:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-26 15:02 Johan Herland [this message]
2010-01-26 20:02 ` [PATCH] builtin-config: Fix crash when using "-f <relative path>" from non-root dir Junio C Hamano
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=201001261602.16876.johan@herland.net \
--to=johan@herland.net \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).