Skip to content

Commit 3d3c118

Browse files
committed
Sync with 2.39.3
* maint-2.39: (34 commits) Git 2.39.3 Git 2.38.5 Git 2.37.7 Git 2.36.6 Git 2.35.8 Makefile: force -O0 when compiling with SANITIZE=leak Git 2.34.8 Git 2.33.8 Git 2.32.7 Git 2.31.8 tests: avoid using `test_i18ncmp` Git 2.30.9 gettext: avoid using gettext if the locale dir is not present apply --reject: overwrite existing `.rej` symlink if it exists http.c: clear the 'finished' member once we are done with it clone.c: avoid "exceeds maximum object size" error with GCC v12.x t5604: GETTEXT_POISON fix, conclusion t5604: GETTEXT_POISON fix, part 1 t5619: GETTEXT_POISON fix range-diff: use ssize_t for parsed "len" in read_patches() ...
2 parents 73876f4 + 9bbde12 commit 3d3c118

File tree

16 files changed

+200
-16
lines changed

16 files changed

+200
-16
lines changed

Documentation/RelNotes/2.30.9.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Git v2.30.9 Release Notes
2+
=========================
3+
4+
This release addresses the security issues CVE-2023-25652,
5+
CVE-2023-25815, and CVE-2023-29007.
6+
7+
8+
Fixes since v2.30.8
9+
-------------------
10+
11+
* CVE-2023-25652:
12+
13+
By feeding specially crafted input to `git apply --reject`, a
14+
path outside the working tree can be overwritten with partially
15+
controlled contents (corresponding to the rejected hunk(s) from
16+
the given patch).
17+
18+
* CVE-2023-25815:
19+
20+
When Git is compiled with runtime prefix support and runs without
21+
translated messages, it still used the gettext machinery to
22+
display messages, which subsequently potentially looked for
23+
translated messages in unexpected places. This allowed for
24+
malicious placement of crafted messages.
25+
26+
* CVE-2023-29007:
27+
28+
When renaming or deleting a section from a configuration file,
29+
certain malicious configuration values may be misinterpreted as
30+
the beginning of a new configuration section, leading to arbitrary
31+
configuration injection.
32+
33+
Credit for finding CVE-2023-25652 goes to Ry0taK, and the fix was
34+
developed by Taylor Blau, Junio C Hamano and Johannes Schindelin,
35+
with the help of Linus Torvalds.
36+
37+
Credit for finding CVE-2023-25815 goes to Maxime Escourbiac and
38+
Yassine BENGANA of Michelin, and the fix was developed by Johannes
39+
Schindelin.
40+
41+
Credit for finding CVE-2023-29007 goes to André Baptista and Vítor Pinho
42+
of Ethiack, and the fix was developed by Taylor Blau, and Johannes
43+
Schindelin, with help from Jeff King, and Patrick Steinhardt.

Documentation/RelNotes/2.31.8.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.31.8 Release Notes
2+
=========================
3+
4+
This release merges the fixes that appear in v2.30.9 to address the
5+
security issues CVE-2023-25652, CVE-2023-25815, and CVE-2023-29007;
6+
see the release notes for that version for details.

Documentation/RelNotes/2.32.7.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.32.7 Release Notes
2+
=========================
3+
4+
This release merges the fixes that appear in v2.30.9 and v2.31.8 to
5+
address the security issues CVE-2023-25652, CVE-2023-25815, and
6+
CVE-2023-29007; see the release notes for these versions for
7+
details.

Documentation/RelNotes/2.33.8.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.33.8 Release Notes
2+
=========================
3+
4+
This release merges the fixes that appear in v2.30.9, v2.31.8 and
5+
v2.32.7 to address the security issues CVE-2023-25652,
6+
CVE-2023-25815, and CVE-2023-29007; see the release notes for these
7+
versions for details.

Documentation/RelNotes/2.34.8.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.34.8 Release Notes
2+
=========================
3+
4+
This release merges the fixes that appear in v2.30.9, v2.31.8,
5+
v2.32.7 and v2.33.8 to address the security issues CVE-2023-25652,
6+
CVE-2023-25815, and CVE-2023-29007; see the release notes for these
7+
versions for details.

Documentation/RelNotes/2.35.8.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.35.8 Release Notes
2+
=========================
3+
4+
This release merges the fixes that appear in v2.30.9, v2.31.8,
5+
v2.32.7, v2.33.8 and v2.34.8 to address the security issues
6+
CVE-2023-25652, CVE-2023-25815, and CVE-2023-29007; see the release
7+
notes for these versions for details.

Documentation/RelNotes/2.36.6.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.36.6 Release Notes
2+
=========================
3+
4+
This release merges the fixes that appear in v2.30.9, v2.31.8,
5+
v2.32.7, v2.33.8, v2.34.8 and v2.35.8 to address the security issues
6+
CVE-2023-25652, CVS-2023-25815, and CVE-2023-29007; see the release
7+
notes for these versions for details.

Documentation/RelNotes/2.37.7.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.37.7 Release Notes
2+
=========================
3+
4+
This release merges up the fix that appears in v2.30.9, v2.31.8,
5+
v2.32.7, v2.33.8, v2.34.8, v2.35.8 and v2.36.6 to address the
6+
security issues CVE-2023-25652, CVE-2023-25815, and CVE-2023-29007;
7+
see the release notes for these versions for details.

Documentation/RelNotes/2.38.5.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Git v2.38.5 Release Notes
2+
=========================
3+
4+
This release merges up the fix that appears in v2.30.9, v2.31.8,
5+
v2.32.7, v2.33.8, v2.34.8, v2.35.8, v2.36.6 and v2.37.7 to address
6+
the security issues CVE-2023-25652, CVE-2023-25815, and
7+
CVE-2023-29007; see the release notes for these versions for
8+
details.

Documentation/RelNotes/2.39.3.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
Git v2.39.3 Release Notes
22
=========================
33

4-
This release is primarily to merge fixes accumulated on the 'master'
5-
front to prepare for 2.40 release that are still relevant to 2.39.x
6-
maintenance track.
4+
This release merges up the fix that appears in v2.30.9, v2.31.8,
5+
v2.32.7, v2.33.8, v2.34.8, v2.35.8, v2.36.6, v2.37.7 and v2.38.5 to
6+
address the security issues CVE-2023-25652, CVE-2023-25815, and
7+
CVE-2023-29007; see the release notes for these versions for
8+
details.
9+
10+
This release also merges fixes that have accumulated on the 'master'
11+
front to prepare for the 2.40 release that are still relevant to
12+
2.39.x maintenance track.
713

814
Fixes since v2.39.2
915
-------------------

apply.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4576,7 +4576,7 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
45764576
FILE *rej;
45774577
char namebuf[PATH_MAX];
45784578
struct fragment *frag;
4579-
int cnt = 0;
4579+
int fd, cnt = 0;
45804580
struct strbuf sb = STRBUF_INIT;
45814581

45824582
for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
@@ -4616,7 +4616,17 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
46164616
memcpy(namebuf, patch->new_name, cnt);
46174617
memcpy(namebuf + cnt, ".rej", 5);
46184618

4619-
rej = fopen(namebuf, "w");
4619+
fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
4620+
if (fd < 0) {
4621+
if (errno != EEXIST)
4622+
return error_errno(_("cannot open %s"), namebuf);
4623+
if (unlink(namebuf))
4624+
return error_errno(_("cannot unlink '%s'"), namebuf);
4625+
fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
4626+
if (fd < 0)
4627+
return error_errno(_("cannot open %s"), namebuf);
4628+
}
4629+
rej = fdopen(fd, "w");
46204630
if (!rej)
46214631
return error_errno(_("cannot open %s"), namebuf);
46224632

config.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3487,9 +3487,10 @@ void git_config_set_multivar(const char *key, const char *value,
34873487
flags);
34883488
}
34893489

3490-
static int section_name_match (const char *buf, const char *name)
3490+
static size_t section_name_match (const char *buf, const char *name)
34913491
{
3492-
int i = 0, j = 0, dot = 0;
3492+
size_t i = 0, j = 0;
3493+
int dot = 0;
34933494
if (buf[i] != '[')
34943495
return 0;
34953496
for (i = 1; buf[i] && buf[i] != ']'; i++) {
@@ -3542,6 +3543,8 @@ static int section_name_is_ok(const char *name)
35423543
return 1;
35433544
}
35443545

3546+
#define GIT_CONFIG_MAX_LINE_LEN (512 * 1024)
3547+
35453548
/* if new_name == NULL, the section is removed instead */
35463549
static int git_config_copy_or_rename_section_in_file(const char *config_filename,
35473550
const char *old_name,
@@ -3551,11 +3554,12 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
35513554
char *filename_buf = NULL;
35523555
struct lock_file lock = LOCK_INIT;
35533556
int out_fd;
3554-
char buf[1024];
3557+
struct strbuf buf = STRBUF_INIT;
35553558
FILE *config_file = NULL;
35563559
struct stat st;
35573560
struct strbuf copystr = STRBUF_INIT;
35583561
struct config_store_data store;
3562+
uint32_t line_nr = 0;
35593563

35603564
memset(&store, 0, sizeof(store));
35613565

@@ -3592,16 +3596,25 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
35923596
goto out;
35933597
}
35943598

3595-
while (fgets(buf, sizeof(buf), config_file)) {
3596-
unsigned i;
3597-
int length;
3599+
while (!strbuf_getwholeline(&buf, config_file, '\n')) {
3600+
size_t i, length;
35983601
int is_section = 0;
3599-
char *output = buf;
3600-
for (i = 0; buf[i] && isspace(buf[i]); i++)
3602+
char *output = buf.buf;
3603+
3604+
line_nr++;
3605+
3606+
if (buf.len >= GIT_CONFIG_MAX_LINE_LEN) {
3607+
ret = error(_("refusing to work with overly long line "
3608+
"in '%s' on line %"PRIuMAX),
3609+
config_filename, (uintmax_t)line_nr);
3610+
goto out;
3611+
}
3612+
3613+
for (i = 0; buf.buf[i] && isspace(buf.buf[i]); i++)
36013614
; /* do nothing */
3602-
if (buf[i] == '[') {
3615+
if (buf.buf[i] == '[') {
36033616
/* it's a section */
3604-
int offset;
3617+
size_t offset;
36053618
is_section = 1;
36063619

36073620
/*
@@ -3618,7 +3631,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
36183631
strbuf_reset(&copystr);
36193632
}
36203633

3621-
offset = section_name_match(&buf[i], old_name);
3634+
offset = section_name_match(&buf.buf[i], old_name);
36223635
if (offset > 0) {
36233636
ret++;
36243637
if (!new_name) {
@@ -3693,6 +3706,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
36933706
out_no_rollback:
36943707
free(filename_buf);
36953708
config_store_data_clear(&store);
3709+
strbuf_release(&buf);
36963710
return ret;
36973711
}
36983712

gettext.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ static void init_gettext_charset(const char *domain)
100100
setlocale(LC_CTYPE, "C");
101101
}
102102

103+
int git_gettext_enabled = 0;
104+
103105
void git_setup_gettext(void)
104106
{
105107
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
@@ -119,6 +121,8 @@ void git_setup_gettext(void)
119121
init_gettext_charset("git");
120122
textdomain("git");
121123

124+
git_gettext_enabled = 1;
125+
122126
free(p);
123127
}
124128

gettext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
3030

3131
#ifndef NO_GETTEXT
32+
extern int git_gettext_enabled;
3233
void git_setup_gettext(void);
3334
int gettext_width(const char *s);
3435
#else
36+
#define git_gettext_enabled (0)
3537
static inline void git_setup_gettext(void)
3638
{
3739
}
@@ -45,12 +47,16 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
4547
{
4648
if (!*msgid)
4749
return "";
50+
if (!git_gettext_enabled)
51+
return msgid;
4852
return gettext(msgid);
4953
}
5054

5155
static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
5256
const char *Q_(const char *msgid, const char *plu, unsigned long n)
5357
{
58+
if (!git_gettext_enabled)
59+
return n == 1 ? msgid : plu;
5460
return ngettext(msgid, plu, n);
5561
}
5662

t/t1300-config.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,36 @@ test_expect_success 'renaming to bogus section is rejected' '
617617
test_must_fail git config --rename-section branch.zwei "bogus name"
618618
'
619619

620+
test_expect_success 'renaming a section with a long line' '
621+
{
622+
printf "[b]\\n" &&
623+
printf " c = d %1024s [a] e = f\\n" " " &&
624+
printf "[a] g = h\\n"
625+
} >y &&
626+
git config -f y --rename-section a xyz &&
627+
test_must_fail git config -f y b.e
628+
'
629+
630+
test_expect_success 'renaming an embedded section with a long line' '
631+
{
632+
printf "[b]\\n" &&
633+
printf " c = d %1024s [a] [foo] e = f\\n" " " &&
634+
printf "[a] g = h\\n"
635+
} >y &&
636+
git config -f y --rename-section a xyz &&
637+
test_must_fail git config -f y foo.e
638+
'
639+
640+
test_expect_success 'renaming a section with an overly-long line' '
641+
{
642+
printf "[b]\\n" &&
643+
printf " c = d %525000s e" " " &&
644+
printf "[a] g = h\\n"
645+
} >y &&
646+
test_must_fail git config -f y --rename-section a xyz 2>err &&
647+
grep "refusing to work with overly long line in .y. on line 2" err
648+
'
649+
620650
cat >> .git/config << EOF
621651
[branch "zwei"] a = 1 [branch "vier"]
622652
EOF

t/t4115-apply-symlink.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,19 @@ test_expect_success SYMLINKS 'symlink escape when deleting file' '
126126
test_path_is_file .git/delete-me
127127
'
128128

129+
test_expect_success SYMLINKS '--reject removes .rej symlink if it exists' '
130+
test_when_finished "git reset --hard && git clean -dfx" &&
131+
132+
test_commit file &&
133+
echo modified >file.t &&
134+
git diff -- file.t >patch &&
135+
echo modified-again >file.t &&
136+
137+
ln -s foo file.t.rej &&
138+
test_must_fail git apply patch --reject 2>err &&
139+
test_i18ngrep "Rejected hunk" err &&
140+
test_path_is_missing foo &&
141+
test_path_is_file file.t.rej
142+
'
143+
129144
test_done

0 commit comments

Comments
 (0)