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:
authorJunio C Hamano <gitster@pobox.com>2022-01-10 22:52:49 +0300
committerJunio C Hamano <gitster@pobox.com>2022-01-10 22:52:49 +0300
commit09481fec21f339d980fca369be3936964003d38b (patch)
tree744caf847eb0c3da06a9bd80132c95882e3c57f4 /builtin/sparse-checkout.c
parente83ba647f7c61cf945690d6a0bd8c172a6498dc8 (diff)
parenta3eca5844526fd6111e7a1e8bdfa9813673a6f23 (diff)
Merge branch 'ds/sparse-checkout-malformed-pattern-fix'
Certain sparse-checkout patterns that are valid in non-cone mode led to segfault in cone mode, which has been corrected. * ds/sparse-checkout-malformed-pattern-fix: sparse-checkout: refuse to add to bad patterns sparse-checkout: fix OOM error with mixed patterns sparse-checkout: fix segfault on malformed patterns
Diffstat (limited to 'builtin/sparse-checkout.c')
-rw-r--r--builtin/sparse-checkout.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 45e838d8f8..679c107036 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -504,7 +504,7 @@ static void insert_recursive_pattern(struct pattern_list *pl, struct strbuf *pat
char *oldpattern = e->pattern;
size_t newlen;
- if (slash == e->pattern)
+ if (!slash || slash == e->pattern)
break;
newlen = slash - e->pattern;
@@ -612,6 +612,9 @@ static void add_patterns_cone_mode(int argc, const char **argv,
die(_("unable to load existing sparse-checkout patterns"));
free(sparse_filename);
+ if (!existing.use_cone_patterns)
+ die(_("existing sparse-checkout patterns do not use cone mode"));
+
hashmap_for_each_entry(&existing.recursive_hashmap, &iter, pe, ent) {
if (!hashmap_contains_parent(&pl->recursive_hashmap,
pe->pattern, &buffer) ||