<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/apply.c, branch v2.45.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.45.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.45.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-04-25T17:34:24Z</updated>
<entry>
<title>Merge branch 'rj/add-i-leak-fix'</title>
<updated>2024-04-25T17:34:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-25T17:34:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e326e520101dcf43a0499c3adc2df7eca30add2d'/>
<id>urn:sha1:e326e520101dcf43a0499c3adc2df7eca30add2d</id>
<content type='text'>
Leakfix.

* rj/add-i-leak-fix:
  add: plug a leak on interactive_add
  add-patch: plug a leak handling the '/' command
  add-interactive: plug a leak in get_untracked_files
  apply: plug a leak in apply_data
</content>
</entry>
<entry>
<title>apply: plug a leak in apply_data</title>
<updated>2024-04-22T23:27:42Z</updated>
<author>
<name>Rubén Justo</name>
<email>rjusto@gmail.com</email>
</author>
<published>2024-04-22T22:54:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=71c791605365d1873ef631bfc478fcd75080a063'/>
<id>urn:sha1:71c791605365d1873ef631bfc478fcd75080a063</id>
<content type='text'>
We have an execution path in apply_data that leaks the local struct
image.  Plug it.

This leak can be triggered with:

    $ echo foo &gt;file
    $ git add file &amp;&amp; git commit -m file
    $ echo bar &gt;file
    $ git diff file &gt;diff
    $ sed s/foo/frotz/ &lt;diff &gt;baddiff
    $ git apply --cached &lt;baddiff

Fixing this leak allows us to mark as leak-free the following tests:

    + t2016-checkout-patch.sh
    + t4103-apply-binary.sh
    + t4104-apply-boundary.sh
    + t4113-apply-ending.sh
    + t4117-apply-reject.sh
    + t4123-apply-shrink.sh
    + t4252-am-options.sh
    + t4258-am-quoted-cr.sh

Mark them with "TEST_PASSES_SANITIZE_LEAK=true" to notice and fix
promply any new leak that may be introduced and triggered by them in the
future.

Signed-off-by: Rubén Justo &lt;rjusto@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>apply: avoid using fixed-size buffer in write_out_one_reject()</title>
<updated>2024-04-16T20:38:35Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-04-16T20:16:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=20fee9af9e511a9086aa02992bd27035b914ee14'/>
<id>urn:sha1:20fee9af9e511a9086aa02992bd27035b914ee14</id>
<content type='text'>
On some systems PATH_MAX is not a hard limit.  Support longer paths by
building them on the heap instead of using static buffers.

Take care to work around (arguably buggy) implementations of free(3)
that change errno by calling it only after using the errno value.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/apply-reject-fd-leakfix'</title>
<updated>2024-04-15T21:11:43Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-15T21:11:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ce729ea9bab9d115bdd2343c3ebe361fc6fce2c4'/>
<id>urn:sha1:ce729ea9bab9d115bdd2343c3ebe361fc6fce2c4</id>
<content type='text'>
A file descriptor leak in an error codepath, used when "git apply
--reject" fails to create the *.rej file, has been corrected.

* rs/apply-reject-fd-leakfix:
  apply: don't leak fd on fdopen() error
</content>
</entry>
<entry>
<title>Merge branch 'rs/apply-lift-path-length-limit'</title>
<updated>2024-04-15T21:11:42Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-15T21:11:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c7a9ec4728db6f88c0957789f3b77a3e2e8b0ec9'/>
<id>urn:sha1:c7a9ec4728db6f88c0957789f3b77a3e2e8b0ec9</id>
<content type='text'>
"git apply" has been updated to lift the hardcoded pathname length
limit, which in turn allowed a mksnpath() function that is no
longer used.

* rs/apply-lift-path-length-limit:
  path: remove mksnpath()
  apply: avoid fixed-size buffer in create_one_file()
</content>
</entry>
<entry>
<title>Merge branch 'jc/apply-parse-diff-git-header-names-fix'</title>
<updated>2024-04-09T21:31:43Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-09T21:31:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8289a36f8725d33f5bdff2a5aeaa0b0369ad8ff8'/>
<id>urn:sha1:8289a36f8725d33f5bdff2a5aeaa0b0369ad8ff8</id>
<content type='text'>
"git apply" failed to extract the filename the patch applied to,
when the change was about an empty file created in or deleted from
a directory whose name ends with a SP, which has been corrected.

* jc/apply-parse-diff-git-header-names-fix:
  t4126: fix "funny directory name" test on Windows (again)
  t4126: make sure a directory with SP at the end is usable
  apply: parse names out of "diff --git" more carefully
</content>
</entry>
<entry>
<title>apply: don't leak fd on fdopen() error</title>
<updated>2024-04-05T17:09:26Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-04-05T10:58:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2b1f456adf8f0b574468661a65548106b317459b'/>
<id>urn:sha1:2b1f456adf8f0b574468661a65548106b317459b</id>
<content type='text'>
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>apply: avoid fixed-size buffer in create_one_file()</title>
<updated>2024-04-05T16:49:36Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-04-05T10:53:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9126cb3186112f160a601e9a7eda29dd43227576'/>
<id>urn:sha1:9126cb3186112f160a601e9a7eda29dd43227576</id>
<content type='text'>
PATH_MAX is not always a hard limit and 'path' in create_one_file()
could be longer -- it's taken from the patch file and allocated
dynamically.  Allocate the name of the temporary file on the heap as
well instead of using a fixed-size buffer to avoid that arbitrary limit.

Resist the temptation of using the more convenient mkpath() to avoid
introducing a dependency on a static variable deep inside the apply
machinery.

Take care to work around (arguably buggy) implementations of free(3)
that modify errno, by calling it only after using the errno value.

Suggested-by: Jeff King &lt;peff@peff.net&gt;
Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>apply: parse names out of "diff --git" more carefully</title>
<updated>2024-03-19T22:58:15Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-03-19T22:56:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5ea0176003f4a5f4a2bffbe87b6ba2365bf1c254'/>
<id>urn:sha1:5ea0176003f4a5f4a2bffbe87b6ba2365bf1c254</id>
<content type='text'>
"git apply" uses the pathname parsed out of the "diff --git" header
to decide which path is being patched, but this is used only when
there is no other names available in the patch.  When there is any
content change (like we can see in this patch, that modifies the
contents of "apply.c") or rename (which comes with "rename from" and
"rename to" extended diff headers), the names are available without
having to parse this header.

When we do need to parse this header, a special care needs to be
taken, as the name of a directory or a file can have a SP in it so
it is not like "find a space, and take everything before the space
and that is the preimage filename, everything after the space is the
postimage filename".  We have a loop that stops at every SP on the
"diff --git a/dir/file b/dir/foo" line and see if that SP is the
right place that separates such a pair of names.

Unfortunately, this loop can terminate prematurely when a crafted
directory name ended with a SP.  The next pathname component after
that SP (i.e. the beginning of the possible postimage filename) will
be a slash, and instead of rejecting that position as the valid
separation point between pre- and post-image filenames and keep
looping, we stopped processing right there.

The fix is simple.  Instead of stopping and giving up, keep going on
when we see such a condition.

Reported-by: Han Young &lt;hanyang.tony@bytedance.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jc/am-whitespace-doc'</title>
<updated>2024-02-28T00:04:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-02-28T00:04:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=45072eefef522935c7cb8cbf5ee8226aba2406ac'/>
<id>urn:sha1:45072eefef522935c7cb8cbf5ee8226aba2406ac</id>
<content type='text'>
"git am --help" now tells readers what actions are available in
"git am --whitespace=&lt;action&gt;", in addition to saying that the
option is passed through to the underlying "git apply".

* jc/am-whitespace-doc:
  doc: add shortcut to "am --whitespace=&lt;action&gt;"
</content>
</entry>
</feed>
