Skip to content

Commit 1df551c

Browse files
committed
Sync with 2.36.6
* maint-2.36: (30 commits) Git 2.36.6 Git 2.35.8 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 range-diff: use ssize_t for parsed "len" in read_patches() range-diff: handle unterminated lines in read_patches() range-diff: drop useless "offset" variable from read_patches() t5604: GETTEXT_POISON fix, conclusion t5604: GETTEXT_POISON fix, part 1 t5619: GETTEXT_POISON fix t0003: GETTEXT_POISON fix, conclusion t0003: GETTEXT_POISON fix, part 1 t0033: GETTEXT_POISON fix ...
2 parents eb88fe1 + ecaa3db commit 1df551c

File tree

17 files changed

+189
-28
lines changed

17 files changed

+189
-28
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ jobs:
232232
- jobname: linux-gcc
233233
cc: gcc
234234
cc_package: gcc-8
235-
pool: ubuntu-latest
235+
pool: ubuntu-20.04
236236
- jobname: linux-TEST-vars
237237
cc: gcc
238238
os: ubuntu
239239
cc_package: gcc-8
240-
pool: ubuntu-latest
240+
pool: ubuntu-20.04
241241
- jobname: osx-clang
242242
cc: clang
243243
pool: macos-latest

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.

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
13241324
endif
13251325
ifneq ($(filter leak,$(SANITIZERS)),)
13261326
BASIC_CFLAGS += -DSUPPRESS_ANNOTATED_LEAKS
1327+
BASIC_CFLAGS += -O0
13271328
SANITIZE_LEAK = YesCompiledWithIt
13281329
endif
13291330
ifneq ($(filter address,$(SANITIZERS)),)

apply.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4566,7 +4566,7 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
45664566
FILE *rej;
45674567
char namebuf[PATH_MAX];
45684568
struct fragment *frag;
4569-
int cnt = 0;
4569+
int fd, cnt = 0;
45704570
struct strbuf sb = STRBUF_INIT;
45714571

45724572
for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
@@ -4606,7 +4606,17 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
46064606
memcpy(namebuf, patch->new_name, cnt);
46074607
memcpy(namebuf + cnt, ".rej", 5);
46084608

4609-
rej = fopen(namebuf, "w");
4609+
fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
4610+
if (fd < 0) {
4611+
if (errno != EEXIST)
4612+
return error_errno(_("cannot open %s"), namebuf);
4613+
if (unlink(namebuf))
4614+
return error_errno(_("cannot unlink '%s'"), namebuf);
4615+
fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
4616+
if (fd < 0)
4617+
return error_errno(_("cannot open %s"), namebuf);
4618+
}
4619+
rej = fdopen(fd, "w");
46104620
if (!rej)
46114621
return error_errno(_("cannot open %s"), namebuf);
46124622

ci/install-dependencies.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
. ${0%/*}/lib.sh
77

8-
P4WHENCE=https://cdist2.perforce.com/perforce/r$LINUX_P4_VERSION
8+
P4WHENCE=https://cdist2.perforce.com/perforce/r21.2
99
LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
1010
UBUNTU_COMMON_PKGS="make libssl-dev libcurl4-openssl-dev libexpat-dev
1111
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl
1212
libemail-valid-perl libio-socket-ssl-perl libnet-smtp-ssl-perl"
1313

1414
case "$runs_on_pool" in
15-
ubuntu-latest)
15+
ubuntu-*)
1616
sudo apt-get -q update
1717
sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \
18-
$UBUNTU_COMMON_PKGS $CC_PACKAGE
18+
$UBUNTU_COMMON_PKGS $CC_PACKAGE $PYTHON_PACKAGE
1919
mkdir --parents "$P4_PATH"
2020
pushd "$P4_PATH"
2121
wget --quiet "$P4WHENCE/bin.linux26x86_64/p4d"
@@ -40,7 +40,7 @@ macos-latest)
4040
mkdir -p $HOME/bin
4141
(
4242
cd $HOME/bin
43-
wget -q "https://cdist2.perforce.com/perforce/r21.2/bin.macosx1015x86_64/helix-core-server.tgz" &&
43+
wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
4444
tar -xf helix-core-server.tgz &&
4545
sudo xattr -d com.apple.quarantine p4 p4d 2>/dev/null || true
4646
)
@@ -83,11 +83,9 @@ esac
8383
if type p4d >/dev/null 2>&1 && type p4 >/dev/null 2>&1
8484
then
8585
echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)"
86-
p4d -V | grep Rev.
86+
p4d -V
8787
echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)"
88-
p4 -V | grep Rev.
89-
else
90-
echo >&2 "WARNING: perforce wasn't installed, see above for clues why"
88+
p4 -V
9189
fi
9290
if type git-lfs >/dev/null 2>&1
9391
then

ci/lib.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,18 @@ export GIT_TEST_CLONE_2GB=true
226226
export SKIP_DASHED_BUILT_INS=YesPlease
227227

228228
case "$runs_on_pool" in
229-
ubuntu-latest)
229+
ubuntu-*)
230230
if test "$jobname" = "linux-gcc-default"
231231
then
232232
break
233233
fi
234234

235+
PYTHON_PACKAGE=python2
235236
if [ "$jobname" = linux-gcc ]
236237
then
237-
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3"
238-
else
239-
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python2"
238+
PYTHON_PACKAGE=python3
240239
fi
240+
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/$PYTHON_PACKAGE"
241241

242242
export GIT_TEST_HTTPD=true
243243

@@ -246,7 +246,6 @@ ubuntu-latest)
246246
# were recorded in the Homebrew database upon creating the OS X
247247
# image.
248248
# Keep that in mind when you encounter a broken OS X build!
249-
export LINUX_P4_VERSION="16.2"
250249
export LINUX_GIT_LFS_VERSION="1.5.2"
251250

252251
P4_PATH="$HOME/custom/p4"

config.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3438,9 +3438,10 @@ void git_config_set_multivar(const char *key, const char *value,
34383438
flags);
34393439
}
34403440

3441-
static int section_name_match (const char *buf, const char *name)
3441+
static size_t section_name_match (const char *buf, const char *name)
34423442
{
3443-
int i = 0, j = 0, dot = 0;
3443+
size_t i = 0, j = 0;
3444+
int dot = 0;
34443445
if (buf[i] != '[')
34453446
return 0;
34463447
for (i = 1; buf[i] && buf[i] != ']'; i++) {
@@ -3493,6 +3494,8 @@ static int section_name_is_ok(const char *name)
34933494
return 1;
34943495
}
34953496

3497+
#define GIT_CONFIG_MAX_LINE_LEN (512 * 1024)
3498+
34963499
/* if new_name == NULL, the section is removed instead */
34973500
static int git_config_copy_or_rename_section_in_file(const char *config_filename,
34983501
const char *old_name,
@@ -3502,11 +3505,12 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
35023505
char *filename_buf = NULL;
35033506
struct lock_file lock = LOCK_INIT;
35043507
int out_fd;
3505-
char buf[1024];
3508+
struct strbuf buf = STRBUF_INIT;
35063509
FILE *config_file = NULL;
35073510
struct stat st;
35083511
struct strbuf copystr = STRBUF_INIT;
35093512
struct config_store_data store;
3513+
uint32_t line_nr = 0;
35103514

35113515
memset(&store, 0, sizeof(store));
35123516

@@ -3543,16 +3547,25 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
35433547
goto out;
35443548
}
35453549

3546-
while (fgets(buf, sizeof(buf), config_file)) {
3547-
unsigned i;
3548-
int length;
3550+
while (!strbuf_getwholeline(&buf, config_file, '\n')) {
3551+
size_t i, length;
35493552
int is_section = 0;
3550-
char *output = buf;
3551-
for (i = 0; buf[i] && isspace(buf[i]); i++)
3553+
char *output = buf.buf;
3554+
3555+
line_nr++;
3556+
3557+
if (buf.len >= GIT_CONFIG_MAX_LINE_LEN) {
3558+
ret = error(_("refusing to work with overly long line "
3559+
"in '%s' on line %"PRIuMAX),
3560+
config_filename, (uintmax_t)line_nr);
3561+
goto out;
3562+
}
3563+
3564+
for (i = 0; buf.buf[i] && isspace(buf.buf[i]); i++)
35523565
; /* do nothing */
3553-
if (buf[i] == '[') {
3566+
if (buf.buf[i] == '[') {
35543567
/* it's a section */
3555-
int offset;
3568+
size_t offset;
35563569
is_section = 1;
35573570

35583571
/*
@@ -3569,7 +3582,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
35693582
strbuf_reset(&copystr);
35703583
}
35713584

3572-
offset = section_name_match(&buf[i], old_name);
3585+
offset = section_name_match(&buf.buf[i], old_name);
35733586
if (offset > 0) {
35743587
ret++;
35753588
if (!new_name) {
@@ -3644,6 +3657,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
36443657
out_no_rollback:
36453658
free(filename_buf);
36463659
config_store_data_clear(&store);
3660+
strbuf_release(&buf);
36473661
return ret;
36483662
}
36493663

gettext.c

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

105+
int git_gettext_enabled = 0;
106+
105107
void git_setup_gettext(void)
106108
{
107109
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
@@ -121,6 +123,8 @@ void git_setup_gettext(void)
121123
init_gettext_charset("git");
122124
textdomain("git");
123125

126+
git_gettext_enabled = 1;
127+
124128
free(p);
125129
}
126130

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

0 commit comments

Comments
 (0)