<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git, branch v2.30.9</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=v2.30.9</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=v2.30.9'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2023-04-17T19:15:43Z</updated>
<entry>
<title>Git 2.30.9</title>
<updated>2023-04-17T19:15:43Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2023-04-14T15:54:08Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=668f2d53613ac8fd373926ebe219f2c29112d93e'/>
<id>urn:sha1:668f2d53613ac8fd373926ebe219f2c29112d93e</id>
<content type='text'>
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
</content>
</entry>
<entry>
<title>Merge branch 'tb/config-copy-or-rename-in-file-injection'</title>
<updated>2023-04-17T19:15:42Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2023-04-14T15:46:59Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=528290f8c61222433a8cf02fb7cfffa8438432b4'/>
<id>urn:sha1:528290f8c61222433a8cf02fb7cfffa8438432b4</id>
<content type='text'>
Avoids issues with renaming or deleting sections with long lines, where
configuration values may be interpreted as sections, leading to
configuration injection. Addresses CVE-2023-29007.

* tb/config-copy-or-rename-in-file-injection:
  config.c: disallow overly-long lines in `copy_or_rename_section_in_file()`
  config.c: avoid integer truncation in `copy_or_rename_section_in_file()`
  config: avoid fixed-sized buffer when renaming/deleting a section
  t1300: demonstrate failure when renaming sections with long lines

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'avoid-using-uninitialized-gettext'</title>
<updated>2023-04-17T19:15:42Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2023-03-14T20:32:42Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=4fe5d0b10afdc9ac5b703605b8d84d1ce5d71e87'/>
<id>urn:sha1:4fe5d0b10afdc9ac5b703605b8d84d1ce5d71e87</id>
<content type='text'>
Avoids the overhead of calling `gettext` when initialization of the
translated messages was skipped. Addresses CVE-2023-25815.

* avoid-using-uninitialized-gettext: (1 commit)
  gettext: avoid using gettext if the locale dir is not present
</content>
</entry>
<entry>
<title>Merge branch 'js/apply-overwrite-rej-symlink-if-exists' into maint-2.30</title>
<updated>2023-04-17T19:15:41Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-03-02T23:13:30Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=18e2b1cfc80990719275d7b08e6e50f3e8cbc902'/>
<id>urn:sha1:18e2b1cfc80990719275d7b08e6e50f3e8cbc902</id>
<content type='text'>
Address CVE-2023-25652 by deleting any existing `.rej` symbolic links
instead of following them.

* js/apply-overwrite-rej-symlink-if-exists:
  apply --reject: overwrite existing `.rej` symlink if it exists

Signed-off-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
</content>
</entry>
<entry>
<title>config.c: disallow overly-long lines in `copy_or_rename_section_in_file()`</title>
<updated>2023-04-17T19:15:40Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2023-04-12T23:18:28Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=3bb3d6bac5f2b496dfa2862dc1a84cbfa9b4449a'/>
<id>urn:sha1:3bb3d6bac5f2b496dfa2862dc1a84cbfa9b4449a</id>
<content type='text'>
As a defense-in-depth measure to guard against any potentially-unknown
buffer overflows in `copy_or_rename_section_in_file()`, refuse to work
with overly-long lines in a gitconfig.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
</content>
</entry>
<entry>
<title>config.c: avoid integer truncation in `copy_or_rename_section_in_file()`</title>
<updated>2023-04-17T19:15:40Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2023-04-06T18:28:53Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=e91cfe6085c4a61372d1f800b473b73b8d225d0d'/>
<id>urn:sha1:e91cfe6085c4a61372d1f800b473b73b8d225d0d</id>
<content type='text'>
There are a couple of spots within `copy_or_rename_section_in_file()`
that incorrectly use an `int` to track an offset within a string, which
may truncate or wrap around to a negative value.

Historically it was impossible to have a line longer than 1024 bytes
anyway, since we used fgets() with a fixed-size buffer of exactly that
length. But the recent change to use a strbuf permits us to read lines
of arbitrary length, so it's possible for a malicious input to cause us
to overflow past INT_MAX and do an out-of-bounds array read.

Practically speaking, however, this should never happen, since it
requires 2GB section names or values, which are unrealistic in
non-malicious circumstances.

Co-authored-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>config: avoid fixed-sized buffer when renaming/deleting a section</title>
<updated>2023-04-17T19:15:40Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2023-04-06T18:07:58Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=a5bb10fd5e74101e7c07da93e7c32bbe60f6173a'/>
<id>urn:sha1:a5bb10fd5e74101e7c07da93e7c32bbe60f6173a</id>
<content type='text'>
When renaming (or deleting) a section of configuration, Git uses the
function `git_config_copy_or_rename_section_in_file()` to rewrite the
configuration file after applying the rename or deletion to the given
section.

To do this, Git repeatedly calls `fgets()` to read the existing
configuration data into a fixed size buffer.

When the configuration value under `old_name` exceeds the size of the
buffer, we will call `fgets()` an additional time even if there is no
newline in the configuration file, since our read length is capped at
`sizeof(buf)`.

If the first character of the buffer (after zero or more characters
satisfying `isspace()`) is a '[', Git will incorrectly treat it as
beginning a new section when the original section is being removed. In
other words, a configuration value satisfying this criteria can
incorrectly be considered as a new secftion instead of a variable in the
original section.

Avoid this issue by using a variable-width buffer in the form of a
strbuf rather than a fixed-with region on the stack. A couple of small
points worth noting:

  - Using a strbuf will cause us to allocate arbitrary sizes to match
    the length of each line.  In practice, we don't expect any
    reasonable configuration files to have lines that long, and a
    bandaid will be introduced in a later patch to ensure that this is
    the case.

  - We are using strbuf_getwholeline() here instead of strbuf_getline()
    in order to match `fgets()`'s behavior of leaving the trailing LF
    character on the buffer (as well as a trailing NUL).

    This could be changed later, but using strbuf_getwholeline() changes
    the least about this function's implementation, so it is picked as
    the safest path.

  - It is temping to want to replace the loop to skip over characters
    matching isspace() at the beginning of the buffer with a convenience
    function like `strbuf_ltrim()`. But this is the wrong approach for a
    couple of reasons:

    First, it involves a potentially large and expensive `memmove()`
    which we would like to avoid. Second, and more importantly, we also
    *do* want to preserve those spaces to avoid changing the output of
    other sections.

In all, this patch is a minimal replacement of the fixed-width buffer in
`git_config_copy_or_rename_section_in_file()` to instead use a `struct
strbuf`.

Reported-by: André Baptista &lt;andre@ethiack.com&gt;
Reported-by: Vítor Pinho &lt;vitor@ethiack.com&gt;
Helped-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Co-authored-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Signed-off-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>gettext: avoid using gettext if the locale dir is not present</title>
<updated>2023-04-17T19:15:39Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2023-02-22T11:40:55Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=c4137be0f5a6edf9a9044e6e43ecf4468c7a4046'/>
<id>urn:sha1:c4137be0f5a6edf9a9044e6e43ecf4468c7a4046</id>
<content type='text'>
In cc5e1bf99247 (gettext: avoid initialization if the locale dir is not
present, 2018-04-21) Git was taught to avoid a costly gettext start-up
when there are not even any localized messages to work with.

But we still called `gettext()` and `ngettext()` functions.

Which caused a problem in Git for Windows when the libgettext that is
consumed from the MSYS2 project stopped using a runtime prefix in
https://github.com/msys2/MINGW-packages/pull/10461

Due to that change, we now use an unintialized gettext machinery that
might get auto-initialized _using an unintended locale directory_:
`C:\mingw64\share\locale`.

Let's record the fact when the gettext initialization was skipped, and
skip calling the gettext functions accordingly.

This addresses CVE-2023-25815.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
</content>
</entry>
<entry>
<title>t1300: demonstrate failure when renaming sections with long lines</title>
<updated>2023-04-17T19:15:39Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2023-04-06T15:42:03Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=29198213c9163c1d552ee2bdbf78d2b09ccc98b8'/>
<id>urn:sha1:29198213c9163c1d552ee2bdbf78d2b09ccc98b8</id>
<content type='text'>
When renaming a configuration section which has an entry whose length
exceeds the size of our buffer in config.c's implementation of
`git_config_copy_or_rename_section_in_file()`, Git will incorrectly
form a new configuration section with part of the data in the section
being removed.

In this instance, our first configuration file looks something like:

    [b]
      c = d &lt;spaces&gt; [a] e = f
    [a]
      g = h

Here, we have two configuration values, "b.c", and "a.g". The value "[a]
e = f" belongs to the configuration value "b.c", and does not form its
own section.

However, when renaming the section 'a' to 'xyz', Git will write back
"[xyz]\ne = f", but "[xyz]" is still attached to the value of "b.c",
which is why "e = f" on its own line becomes a new entry called "b.e".

A slightly different example embeds the section being renamed within
another section.

Demonstrate this failure in a test in t1300, which we will fix in the
following commit.

Co-authored-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>apply --reject: overwrite existing `.rej` symlink if it exists</title>
<updated>2023-04-17T19:15:38Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2023-03-09T15:02:54Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=9db05711c98efc14f414d4c87135a34c13586e0b'/>
<id>urn:sha1:9db05711c98efc14f414d4c87135a34c13586e0b</id>
<content type='text'>
The `git apply --reject` is expected to write out `.rej` files in case
one or more hunks fail to apply cleanly. Historically, the command
overwrites any existing `.rej` files. The idea being that
apply/reject/edit cycles are relatively common, and the generated `.rej`
files are not considered precious.

But the command does not overwrite existing `.rej` symbolic links, and
instead follows them. This is unsafe because the same patch could
potentially create such a symbolic link and point at arbitrary paths
outside the current worktree, and `git apply` would write the contents
of the `.rej` file into that location.

Therefore, let's make sure that any existing `.rej` file or symbolic
link is removed before writing it.

Reported-by: RyotaK &lt;ryotak.mail@gmail.com&gt;
Helped-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Helped-by: Linus Torvalds &lt;torvalds@linuxfoundation.org&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
</content>
</entry>
</feed>
