summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c2c9be)
raw | patch | inline | side by side (parent: 1c2c9be)
author | Jeff King <peff@peff.net> | |
Thu, 9 Jun 2011 15:52:43 +0000 (11:52 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 22 Jun 2011 18:24:51 +0000 (11:24 -0700) |
We already check for an empty key on the left side of an
equals, but we would segfault if there was no content at
all.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
equals, but we would segfault if there was no content at
all.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c | patch | blob | history | |
t/t1300-repo-config.sh | patch | blob | history |
diff --git a/config.c b/config.c
index 2567b546a36b555cdaa08f19d3a8fea31927505e..9939f65d9e9dfbb7b1f40749a1aaf0850e069350 100644 (file)
--- a/config.c
+++ b/config.c
struct strbuf **pair;
strbuf_addstr(&tmp, text);
pair = strbuf_split_max(&tmp, '=', 2);
+ if (!pair[0])
+ return error("bogus config parameter: %s", text);
if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
strbuf_setlen(pair[0], pair[0]->len - 1);
strbuf_trim(pair[0]);
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 584e956ac5c807a834b8be5fb44e4543cf8172f8..3e140c18f4183c41c76aaab0834f1d23ce7bcd2d 100755 (executable)
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
test_must_fail git -c "=foo" rev-parse
'
+test_expect_success 'git -c complains about empty key and value' '
+ test_must_fail git -c "" rev-parse
+'
+
test_done