summaryrefslogtreecommitdiffstats
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-06-21 00:53:12 +0200
committerJunio C Hamano <gitster@pobox.com>2023-06-21 00:53:13 +0200
commit9cd234e6465ab2bea5c402f0d9ee1495501250ef (patch)
treea49e3100d91ff919f5ff7bfdcf9c665dcc6408a2 /builtin/submodule--helper.c
parentMerge branch 'jc/test-modernization-2' (diff)
parentbuiltin/submodule--helper.c: handle missing submodule URLs (diff)
downloadgit-9cd234e6465ab2bea5c402f0d9ee1495501250ef.tar.xz
git-9cd234e6465ab2bea5c402f0d9ee1495501250ef.zip
Merge branch 'tb/submodule-null-deref-fix'
"git submodule" code trusted the data coming from the config (and the in-tree .gitmodules file) too much without validating, leading to NULL dereference if the user mucks with a repository (e.g. submodule.<name>.url is removed). This has been corrected. * tb/submodule-null-deref-fix: builtin/submodule--helper.c: handle missing submodule URLs
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 6bf8d666ce..6a16208e8a 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2024,14 +2024,17 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
strbuf_reset(&sb);
strbuf_addf(&sb, "submodule.%s.url", sub->name);
if (repo_config_get_string_tmp(the_repository, sb.buf, &url)) {
- if (starts_with_dot_slash(sub->url) ||
- starts_with_dot_dot_slash(sub->url)) {
+ if (sub->url && (starts_with_dot_slash(sub->url) ||
+ starts_with_dot_dot_slash(sub->url))) {
url = resolve_relative_url(sub->url, NULL, 0);
need_free_url = 1;
} else
url = sub->url;
}
+ if (!url)
+ die(_("cannot clone submodule '%s' without a URL"), sub->name);
+
strbuf_reset(&sb);
strbuf_addf(&sb, "%s/.git", ce->name);
needs_cloning = !file_exists(sb.buf);