summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-03-25 14:01:00 -0700
committerJunio C Hamano <gitster@pobox.com>2013-03-25 14:01:00 -0700
commit51ebd0fe9e089df08eeb5b1547f0585c2de13683 (patch)
tree3cfe64ecbbb1e42cb4cf7cc04fbb3f6ec8cb3db0 /setup.c
parent33c1506d6257897040eccc8167584a98fa8f88fe (diff)
parentf612a67eac32d73d781503d39077371977d46eae (diff)
downloadgit-51ebd0fe9e089df08eeb5b1547f0585c2de13683.tar.gz
Merge branch 'lf/setup-prefix-pathspec'
"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
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/setup.c b/setup.c
index 9107f54a07..94c1e61bda 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;