summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2013-04-03 09:24:18 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-04-03 09:24:19 -0700
commitfa0a6a48233d9dd1e72ef3fe13166871a18d7714 (patch)
treec2d4967f270aebb75533b1f300e050056754df9a
parentSync with 1.8.1 maintenance track (diff)
parentsetup.c: check that the pathspec magic ends with ")" (diff)
downloadtgif-fa0a6a48233d9dd1e72ef3fe13166871a18d7714.tar.xz
Merge branch 'lf/setup-prefix-pathspec' into maint
"git cmd -- ':(top'" was not diagnosed as an invalid syntax, and instead the parser kept reading beyond the end of the string. * lf/setup-prefix-pathspec: setup.c: check that the pathspec magic ends with ")" setup.c: stop prefix_pathspec() from looping past the end of string
-rw-r--r--setup.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/setup.c b/setup.c
index 1dee47e085..a2be9690ad 100644
--- a/setup.c
+++ b/setup.c
@@ -207,10 +207,11 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char
*copyfrom && *copyfrom != ')';
copyfrom = nextat) {
size_t len = strcspn(copyfrom, ",)");
- if (copyfrom[len] == ')')
- nextat = copyfrom + len;
- else
+ if (copyfrom[len] == ',')
nextat = copyfrom + len + 1;
+ else
+ /* handle ')' and '\0' */
+ nextat = copyfrom + len;
if (!len)
continue;
for (i = 0; i < ARRAY_SIZE(pathspec_magic); i++)
@@ -223,8 +224,9 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char
die("Invalid pathspec magic '%.*s' in '%s'",
(int) len, copyfrom, elt);
}
- if (*copyfrom == ')')
- copyfrom++;
+ if (*copyfrom != ')')
+ die("Missing ')' at the end of pathspec magic in '%s'", elt);
+ copyfrom++;
} else {
/* shorthand */
for (copyfrom = elt + 1;