Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Wong <andrew.kw.w@gmail.com>2013-03-07 20:36:03 +0400
committerJunio C Hamano <gitster@pobox.com>2013-03-14 20:39:09 +0400
commit772e47cd673e048adb0f7b663617ec70e0cfe598 (patch)
treeb759761f8c13a2e19c67d921d9bcd416f7f5feba /setup.c
parent7e2010537e96d0a1144520222f20ba1dc3d61441 (diff)
setup.c: stop prefix_pathspec() from looping past the end of string
The code assumes that the string ends at either `)` or `,`, and does not handle the case where strcspn() returns length due to end of string. So specifying ":(top" as pathspec will cause the loop to go past the end of string. Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/setup.c b/setup.c
index 3a1b2fd455..e61458a7d0 100644
--- a/setup.c
+++ b/setup.c
@@ -199,10 +199,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++)