Skip to content

Commit 09f66d6

Browse files
committed
Git 2.31.3
Signed-off-by: Junio C Hamano <[email protected]>
2 parents 44de39c + 17083c7 commit 09f66d6

File tree

7 files changed

+92
-5
lines changed

7 files changed

+92
-5
lines changed

Documentation/RelNotes/2.30.4.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Git v2.30.4 Release Notes
2+
=========================
3+
4+
This release contains minor fix-ups for the changes that went into
5+
Git 2.30.3, which was made to address CVE-2022-24765.
6+
7+
* The code that was meant to parse the new `safe.directory`
8+
configuration variable was not checking what configuration
9+
variable was being fed to it, which has been corrected.
10+
11+
* '*' can be used as the value for the `safe.directory` variable to
12+
signal that the user considers that any directory is safe.
13+
14+
15+
16+
Derrick Stolee (2):
17+
t0033: add tests for safe.directory
18+
setup: opt-out of check with safe.directory=*
19+
20+
Matheus Valadares (1):
21+
setup: fix safe.directory key not being checked

Documentation/RelNotes/2.31.3.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git Documentation/RelNotes/2.31.3.txt Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.31.3.

Documentation/config/safe.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ line option `-c safe.directory=<path>`.
1919
The value of this setting is interpolated, i.e. `~/<path>` expands to a
2020
path relative to the home directory and `%(prefix)/<path>` expands to a
2121
path relative to Git's (runtime) prefix.
22+
+
23+
To completely opt-out of this security check, set `safe.directory` to the
24+
string `*`. This will allow all repositories to be treated as if their
25+
directory was listed in the `safe.directory` list. If `safe.directory=*`
26+
is set in system config and you want to re-enable this protection, then
27+
initialize your list with an empty value before listing the repositories
28+
that you deem safe.

GIT-VERSION-GEN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
GVF=GIT-VERSION-FILE
4-
DEF_VER=v2.31.2
4+
DEF_VER=v2.31.3
55

66
LF='
77
'

RelNotes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Documentation/RelNotes/2.31.2.txt
1+
Documentation/RelNotes/2.31.3.txt

setup.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,14 @@ static int safe_directory_cb(const char *key, const char *value, void *d)
10341034
{
10351035
struct safe_directory_data *data = d;
10361036

1037-
if (!value || !*value)
1037+
if (strcmp(key, "safe.directory"))
1038+
return 0;
1039+
1040+
if (!value || !*value) {
10381041
data->is_safe = 0;
1039-
else {
1042+
} else if (!strcmp(value, "*")) {
1043+
data->is_safe = 1;
1044+
} else {
10401045
const char *interpolated = NULL;
10411046

10421047
if (!git_config_pathname(&interpolated, key, value) &&
@@ -1053,7 +1058,8 @@ static int ensure_valid_ownership(const char *path)
10531058
{
10541059
struct safe_directory_data data = { .path = path };
10551060

1056-
if (is_path_owned_by_current_user(path))
1061+
if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0) &&
1062+
is_path_owned_by_current_user(path))
10571063
return 1;
10581064

10591065
read_very_early_config(safe_directory_cb, &data);

t/t0033-safe-directory.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
test_description='verify safe.directory checks'
4+
5+
. ./test-lib.sh
6+
7+
GIT_TEST_ASSUME_DIFFERENT_OWNER=1
8+
export GIT_TEST_ASSUME_DIFFERENT_OWNER
9+
10+
expect_rejected_dir () {
11+
test_must_fail git status 2>err &&
12+
grep "safe.directory" err
13+
}
14+
15+
test_expect_success 'safe.directory is not set' '
16+
expect_rejected_dir
17+
'
18+
19+
test_expect_success 'safe.directory does not match' '
20+
git config --global safe.directory bogus &&
21+
expect_rejected_dir
22+
'
23+
24+
test_expect_success 'path exist as different key' '
25+
git config --global foo.bar "$(pwd)" &&
26+
expect_rejected_dir
27+
'
28+
29+
test_expect_success 'safe.directory matches' '
30+
git config --global --add safe.directory "$(pwd)" &&
31+
git status
32+
'
33+
34+
test_expect_success 'safe.directory matches, but is reset' '
35+
git config --global --add safe.directory "" &&
36+
expect_rejected_dir
37+
'
38+
39+
test_expect_success 'safe.directory=*' '
40+
git config --global --add safe.directory "*" &&
41+
git status
42+
'
43+
44+
test_expect_success 'safe.directory=*, but is reset' '
45+
git config --global --add safe.directory "" &&
46+
expect_rejected_dir
47+
'
48+
49+
test_done

0 commit comments

Comments
 (0)