Skip to content

Commit e43aab7

Browse files
committed
Sync with 2.16.5
* maint-2.16: Git 2.16.5 Git 2.15.3 Git 2.14.5 submodule-config: ban submodule paths that start with a dash submodule-config: ban submodule urls that start with dash submodule--helper: use "--" to signal end of clone options
2 parents fc54c1a + 27d05d1 commit e43aab7

File tree

7 files changed

+93
-0
lines changed

7 files changed

+93
-0
lines changed

Documentation/RelNotes/2.14.5.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Git v2.14.5 Release Notes
2+
=========================
3+
4+
This release is to address the recently reported CVE-2018-17456.
5+
6+
Fixes since v2.14.4
7+
-------------------
8+
9+
* Submodules' "URL"s come from the untrusted .gitmodules file, but
10+
we blindly gave it to "git clone" to clone submodules when "git
11+
clone --recurse-submodules" was used to clone a project that has
12+
such a submodule. The code has been hardened to reject such
13+
malformed URLs (e.g. one that begins with a dash).
14+
15+
Credit for finding and fixing this vulnerability goes to joernchen
16+
and Jeff King, respectively.

Documentation/RelNotes/2.15.3.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.15.3 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.14.5 to address
5+
the recently reported CVE-2018-17456; see the release notes for that
6+
version for details.

Documentation/RelNotes/2.16.5.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.16.5 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.14.5 to address
5+
the recently reported CVE-2018-17456; see the release notes for that
6+
version for details.

builtin/submodule--helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
10781078
if (gitdir && *gitdir)
10791079
argv_array_pushl(&cp.args, "--separate-git-dir", gitdir, NULL);
10801080

1081+
argv_array_push(&cp.args, "--");
10811082
argv_array_push(&cp.args, url);
10821083
argv_array_push(&cp.args, path);
10831084

submodule-config.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ static void warn_multiple_config(const unsigned char *treeish_name,
383383
commit_string, name, option);
384384
}
385385

386+
static void warn_command_line_option(const char *var, const char *value)
387+
{
388+
warning(_("ignoring '%s' which may be interpreted as"
389+
" a command-line option: %s"), var, value);
390+
}
391+
386392
struct parse_config_parameter {
387393
struct submodule_cache *cache;
388394
const unsigned char *treeish_name;
@@ -408,6 +414,8 @@ static int parse_config(const char *var, const char *value, void *data)
408414
if (!strcmp(item.buf, "path")) {
409415
if (!value)
410416
ret = config_error_nonbool(var);
417+
else if (looks_like_command_line_option(value))
418+
warn_command_line_option(var, value);
411419
else if (!me->overwrite && submodule->path)
412420
warn_multiple_config(me->treeish_name, submodule->name,
413421
"path");
@@ -448,6 +456,8 @@ static int parse_config(const char *var, const char *value, void *data)
448456
} else if (!strcmp(item.buf, "url")) {
449457
if (!value) {
450458
ret = config_error_nonbool(var);
459+
} else if (looks_like_command_line_option(value)) {
460+
warn_command_line_option(var, value);
451461
} else if (!me->overwrite && submodule->url) {
452462
warn_multiple_config(me->treeish_name, submodule->name,
453463
"url");

t/t7416-submodule-dash-url.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
test_description='check handling of .gitmodule url with dash'
4+
. ./test-lib.sh
5+
6+
test_expect_success 'create submodule with protected dash in url' '
7+
git init upstream &&
8+
git -C upstream commit --allow-empty -m base &&
9+
mv upstream ./-upstream &&
10+
git submodule add ./-upstream sub &&
11+
git add sub .gitmodules &&
12+
git commit -m submodule
13+
'
14+
15+
test_expect_success 'clone can recurse submodule' '
16+
test_when_finished "rm -rf dst" &&
17+
git clone --recurse-submodules . dst &&
18+
echo base >expect &&
19+
git -C dst/sub log -1 --format=%s >actual &&
20+
test_cmp expect actual
21+
'
22+
23+
test_expect_success 'remove ./ protection from .gitmodules url' '
24+
perl -i -pe "s{\./}{}" .gitmodules &&
25+
git commit -am "drop protection"
26+
'
27+
28+
test_expect_success 'clone rejects unprotected dash' '
29+
test_when_finished "rm -rf dst" &&
30+
test_must_fail git clone --recurse-submodules . dst 2>err &&
31+
test_i18ngrep ignoring err
32+
'
33+
34+
test_done

t/t7417-submodule-path-url.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
test_description='check handling of .gitmodule path with dash'
4+
. ./test-lib.sh
5+
6+
test_expect_success 'create submodule with dash in path' '
7+
git init upstream &&
8+
git -C upstream commit --allow-empty -m base &&
9+
git submodule add ./upstream sub &&
10+
git mv sub ./-sub &&
11+
git commit -m submodule
12+
'
13+
14+
test_expect_success 'clone rejects unprotected dash' '
15+
test_when_finished "rm -rf dst" &&
16+
git clone --recurse-submodules . dst 2>err &&
17+
test_i18ngrep ignoring err
18+
'
19+
20+
test_done

0 commit comments

Comments
 (0)