Skip to content

Commit b524e89

Browse files
committed
Sync with 2.30.9
* maint-2.30: (23 commits) 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 http: support CURLOPT_PROTOCOLS_STR http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT ci: install python on ubuntu ci: use the same version of p4 on both Linux and macOS ci: remove the pipe after "p4 -V" to catch errors github-actions: run gcc-8 on ubuntu-20.04 image ...
2 parents 0bbcf95 + 668f2d5 commit b524e89

File tree

21 files changed

+291
-104
lines changed

21 files changed

+291
-104
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ jobs:
282282
pool: ubuntu-latest
283283
- jobname: linux-gcc
284284
cc: gcc
285-
pool: ubuntu-latest
285+
pool: ubuntu-20.04
286286
- jobname: osx-clang
287287
cc: clang
288288
pool: macos-latest
@@ -340,7 +340,7 @@ jobs:
340340
if: needs.ci-config.outputs.enabled == 'yes'
341341
env:
342342
jobname: StaticAnalysis
343-
runs-on: ubuntu-18.04
343+
runs-on: ubuntu-22.04
344344
steps:
345345
- uses: actions/checkout@v1
346346
- run: ci/install-dependencies.sh

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.

INSTALL

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ Issues of note:
145145
patches into an IMAP mailbox, you do not have to have them
146146
(use NO_CURL).
147147

148+
Git requires version "7.19.5" or later of "libcurl" to build
149+
without NO_CURL. This version requirement may be bumped in
150+
the future.
151+
148152
- "expat" library; git-http-push uses it for remote lock
149153
management over DAV. Similar to "curl" above, this is optional
150154
(with NO_EXPAT).

apply.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4558,7 +4558,7 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
45584558
FILE *rej;
45594559
char namebuf[PATH_MAX];
45604560
struct fragment *frag;
4561-
int cnt = 0;
4561+
int fd, cnt = 0;
45624562
struct strbuf sb = STRBUF_INIT;
45634563

45644564
for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
@@ -4598,7 +4598,17 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
45984598
memcpy(namebuf, patch->new_name, cnt);
45994599
memcpy(namebuf + cnt, ".rej", 5);
46004600

4601-
rej = fopen(namebuf, "w");
4601+
fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
4602+
if (fd < 0) {
4603+
if (errno != EEXIST)
4604+
return error_errno(_("cannot open %s"), namebuf);
4605+
if (unlink(namebuf))
4606+
return error_errno(_("cannot unlink '%s'"), namebuf);
4607+
fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
4608+
if (fd < 0)
4609+
return error_errno(_("cannot open %s"), namebuf);
4610+
}
4611+
rej = fdopen(fd, "w");
46024612
if (!rej)
46034613
return error_errno(_("cannot open %s"), namebuf);
46044614

builtin/clone.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,15 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
250250
end--;
251251
}
252252

253+
/*
254+
* It should not be possible to overflow `ptrdiff_t` by passing in an
255+
* insanely long URL, but GCC does not know that and will complain
256+
* without this check.
257+
*/
258+
if (end - start < 0)
259+
die(_("No directory name could be guessed.\n"
260+
"Please specify a directory on the command line"));
261+
253262
/*
254263
* Strip trailing port number if we've got only a
255264
* hostname (that is, there is no dir separator but a

ci/install-dependencies.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

8-
P4WHENCE=http://filehost.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
@@ -16,7 +16,7 @@ linux-clang|linux-gcc)
1616
sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
1717
sudo apt-get -q update
1818
sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \
19-
$UBUNTU_COMMON_PKGS
19+
$UBUNTU_COMMON_PKGS $PYTHON_PACKAGE
2020
case "$jobname" in
2121
linux-gcc)
2222
sudo apt-get -q -y install gcc-8
@@ -44,13 +44,15 @@ osx-clang|osx-gcc)
4444
test -z "$BREW_INSTALL_PACKAGES" ||
4545
brew install $BREW_INSTALL_PACKAGES
4646
brew link --force gettext
47-
brew install --cask --no-quarantine perforce || {
48-
# Update the definitions and try again
49-
cask_repo="$(brew --repository)"/Library/Taps/homebrew/homebrew-cask &&
50-
git -C "$cask_repo" pull --no-stat --ff-only &&
51-
brew install --cask --no-quarantine perforce
52-
} ||
53-
brew install homebrew/cask/perforce
47+
mkdir -p $HOME/bin
48+
(
49+
cd $HOME/bin
50+
wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
51+
tar -xf helix-core-server.tgz &&
52+
sudo xattr -d com.apple.quarantine p4 p4d 2>/dev/null || true
53+
)
54+
PATH="$PATH:${HOME}/bin"
55+
export PATH
5456
case "$jobname" in
5557
osx-gcc)
5658
brew install gcc@9
@@ -81,9 +83,9 @@ esac
8183
if type p4d >/dev/null && type p4 >/dev/null
8284
then
8385
echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)"
84-
p4d -V | grep Rev.
86+
p4d -V
8587
echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)"
86-
p4 -V | grep Rev.
88+
p4 -V
8789
fi
8890
if type git-lfs >/dev/null
8991
then

ci/lib.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ export SKIP_DASHED_BUILT_INS=YesPlease
184184

185185
case "$jobname" in
186186
linux-clang|linux-gcc)
187+
PYTHON_PACKAGE=python2
187188
if [ "$jobname" = linux-gcc ]
188189
then
189190
export CC=gcc-8
190-
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3"
191-
else
192-
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python2"
191+
PYTHON_PACKAGE=python3
193192
fi
193+
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/$PYTHON_PACKAGE"
194194

195195
export GIT_TEST_HTTPD=true
196196

@@ -199,7 +199,6 @@ linux-clang|linux-gcc)
199199
# were recorded in the Homebrew database upon creating the OS X
200200
# image.
201201
# Keep that in mind when you encounter a broken OS X build!
202-
export LINUX_P4_VERSION="16.2"
203202
export LINUX_GIT_LFS_VERSION="1.5.2"
204203

205204
P4_PATH="$HOME/custom/p4"

compat/nedmalloc/nedmalloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ static NOINLINE void RemoveCacheEntries(nedpool *p, threadcache *tc, unsigned in
323323
}
324324
static void DestroyCaches(nedpool *p) THROWSPEC
325325
{
326-
if(p->caches)
327326
{
328327
threadcache *tc;
329328
int n;

compat/win32/syslog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ void syslog(int priority, const char *fmt, ...)
4343
va_end(ap);
4444

4545
while ((pos = strstr(str, "%1")) != NULL) {
46+
size_t offset = pos - str;
4647
char *oldstr = str;
4748
str = realloc(str, st_add(++str_len, 1));
4849
if (!str) {
4950
free(oldstr);
5051
warning_errno("realloc failed");
5152
return;
5253
}
54+
pos = str + offset;
5355
memmove(pos + 2, pos + 1, strlen(pos));
5456
pos[1] = ' ';
5557
}

config.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3195,9 +3195,10 @@ void git_config_set_multivar(const char *key, const char *value,
31953195
flags);
31963196
}
31973197

3198-
static int section_name_match (const char *buf, const char *name)
3198+
static size_t section_name_match (const char *buf, const char *name)
31993199
{
3200-
int i = 0, j = 0, dot = 0;
3200+
size_t i = 0, j = 0;
3201+
int dot = 0;
32013202
if (buf[i] != '[')
32023203
return 0;
32033204
for (i = 1; buf[i] && buf[i] != ']'; i++) {
@@ -3250,6 +3251,8 @@ static int section_name_is_ok(const char *name)
32503251
return 1;
32513252
}
32523253

3254+
#define GIT_CONFIG_MAX_LINE_LEN (512 * 1024)
3255+
32533256
/* if new_name == NULL, the section is removed instead */
32543257
static int git_config_copy_or_rename_section_in_file(const char *config_filename,
32553258
const char *old_name,
@@ -3259,11 +3262,12 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
32593262
char *filename_buf = NULL;
32603263
struct lock_file lock = LOCK_INIT;
32613264
int out_fd;
3262-
char buf[1024];
3265+
struct strbuf buf = STRBUF_INIT;
32633266
FILE *config_file = NULL;
32643267
struct stat st;
32653268
struct strbuf copystr = STRBUF_INIT;
32663269
struct config_store_data store;
3270+
uint32_t line_nr = 0;
32673271

32683272
memset(&store, 0, sizeof(store));
32693273

@@ -3300,16 +3304,25 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
33003304
goto out;
33013305
}
33023306

3303-
while (fgets(buf, sizeof(buf), config_file)) {
3304-
unsigned i;
3305-
int length;
3307+
while (!strbuf_getwholeline(&buf, config_file, '\n')) {
3308+
size_t i, length;
33063309
int is_section = 0;
3307-
char *output = buf;
3308-
for (i = 0; buf[i] && isspace(buf[i]); i++)
3310+
char *output = buf.buf;
3311+
3312+
line_nr++;
3313+
3314+
if (buf.len >= GIT_CONFIG_MAX_LINE_LEN) {
3315+
ret = error(_("refusing to work with overly long line "
3316+
"in '%s' on line %"PRIuMAX),
3317+
config_filename, (uintmax_t)line_nr);
3318+
goto out;
3319+
}
3320+
3321+
for (i = 0; buf.buf[i] && isspace(buf.buf[i]); i++)
33093322
; /* do nothing */
3310-
if (buf[i] == '[') {
3323+
if (buf.buf[i] == '[') {
33113324
/* it's a section */
3312-
int offset;
3325+
size_t offset;
33133326
is_section = 1;
33143327

33153328
/*
@@ -3326,7 +3339,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
33263339
strbuf_reset(&copystr);
33273340
}
33283341

3329-
offset = section_name_match(&buf[i], old_name);
3342+
offset = section_name_match(&buf.buf[i], old_name);
33303343
if (offset > 0) {
33313344
ret++;
33323345
if (new_name == NULL) {
@@ -3401,6 +3414,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
34013414
out_no_rollback:
34023415
free(filename_buf);
34033416
config_store_data_clear(&store);
3417+
strbuf_release(&buf);
34043418
return ret;
34053419
}
34063420

0 commit comments

Comments
 (0)