<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/libgit2.git/src/apply.c, branch ethomson/v0.28.5</title>
<subtitle>github.com: libgit2/libgit2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/'/>
<entry>
<title>apply: Fix a patch corruption related to EOFNL handling</title>
<updated>2020-03-26T15:20:11+00:00</updated>
<author>
<name>Max Kostyukevich</name>
<email>maxim.kostyukevich@mera.com</email>
</author>
<published>2019-08-20T00:08:32+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=0126e3fc1317cf7a1ef0fd5ad1af460be547701e'/>
<id>0126e3fc1317cf7a1ef0fd5ad1af460be547701e</id>
<content type='text'>
Use of apply's API can lead to an improper patch application and a corruption
of the modified file.

The issue is caused by mishandling of the end of file changes if there are
several hunks to apply. The new line character is added to a line from a wrong
hunk.

The solution is to modify apply_hunk() to add the newline character at the end
of a line from a right hunk.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use of apply's API can lead to an improper patch application and a corruption
of the modified file.

The issue is caused by mishandling of the end of file changes if there are
several hunks to apply. The new line character is added to a line from a wrong
hunk.

The solution is to modify apply_hunk() to add the newline character at the end
of a line from a right hunk.
</pre>
</div>
</content>
</entry>
<entry>
<title>apply: git_apply_to_tree fails to apply patches that add new files</title>
<updated>2020-03-26T15:20:11+00:00</updated>
<author>
<name>Max Kostyukevich</name>
<email>maxim.kostyukevich@mera.com</email>
</author>
<published>2019-08-20T00:29:45+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=d6e5c44f28f96386aa2d6e8b82ca58a0335d340e'/>
<id>d6e5c44f28f96386aa2d6e8b82ca58a0335d340e</id>
<content type='text'>
git_apply_to_tree() cannot be used apply patches with new files. An attempt
to apply such a patch fails because git_apply_to_tree() tries to remove a
non-existing file from an old index.

The solution is to modify git_apply_to_tree() to git_index_remove() when the
patch states that the modified files is removed.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
git_apply_to_tree() cannot be used apply patches with new files. An attempt
to apply such a patch fails because git_apply_to_tree() tries to remove a
non-existing file from an old index.

The solution is to modify git_apply_to_tree() to git_index_remove() when the
patch states that the modified files is removed.
</pre>
</div>
</content>
</entry>
<entry>
<title>patch_parse: ensure valid patch output with EOFNL</title>
<updated>2020-03-26T15:20:11+00:00</updated>
<author>
<name>Erik Aigner</name>
<email>aigner.erik@gmail.com</email>
</author>
<published>2019-07-11T10:12:04+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=16dbedc97231c2ee11e0a66e9d56ecba19937249'/>
<id>16dbedc97231c2ee11e0a66e9d56ecba19937249</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>apply: refactor to use a switch statement</title>
<updated>2020-03-26T15:20:11+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2019-07-11T10:10:48+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=b8339912db0a02091f630c083dc1f4c2cd02cb11'/>
<id>b8339912db0a02091f630c083dc1f4c2cd02cb11</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>apply: prevent OOB read when parsing source buffer</title>
<updated>2020-03-26T15:20:10+00:00</updated>
<author>
<name>Erik Aigner</name>
<email>aigner.erik@gmail.com</email>
</author>
<published>2019-02-20T14:30:11+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=6f351d83e7e0a8ebbd3d83b504bbaa6384343c43'/>
<id>6f351d83e7e0a8ebbd3d83b504bbaa6384343c43</id>
<content type='text'>
When parsing the patch image from a string, we split the string
by newlines to get a line-based view of it. To split, we use
`memchr` on the buffer and limit the buffer length by the
original length provided by the caller. This works just fine for
the first line, but for every subsequent line we need to actually
subtract the amount of bytes that we have already read.

The above issue can be easily triggered by having a source buffer
with at least two lines, where the second line does _not_ end in
a newline. Given a string "foo\nb", we have an original length of
five bytes. After having extracted the first line, we will point
to 'b' and again try to `memchr(p, '\n', 5)`, resulting in an
out-of-bounds read of four bytes.

Fix the issue by correctly subtracting the amount of bytes
already read.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When parsing the patch image from a string, we split the string
by newlines to get a line-based view of it. To split, we use
`memchr` on the buffer and limit the buffer length by the
original length provided by the caller. This works just fine for
the first line, but for every subsequent line we need to actually
subtract the amount of bytes that we have already read.

The above issue can be easily triggered by having a source buffer
with at least two lines, where the second line does _not_ end in
a newline. Given a string "foo\nb", we have an original length of
five bytes. After having extracted the first line, we will point
to 'b' and again try to `memchr(p, '\n', 5)`, resulting in an
out-of-bounds read of four bytes.

Fix the issue by correctly subtracting the amount of bytes
already read.
</pre>
</div>
</content>
</entry>
<entry>
<title>apply: make update_hunk accept a size_t</title>
<updated>2019-01-25T22:47:39+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-01-21T00:49:07+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=ae681d3ff5b6d2518b6625ff1b6f16e9f65a6935'/>
<id>ae681d3ff5b6d2518b6625ff1b6f16e9f65a6935</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>git_error: use new names in internal APIs and usage</title>
<updated>2019-01-22T22:30:35+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2018-12-27T19:47:34+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=f673e232afe22eb865cdc915e55a2df6493f0fbb'/>
<id>f673e232afe22eb865cdc915e55a2df6493f0fbb</id>
<content type='text'>
Move to the `git_error` name in the internal API for error-related
functions.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move to the `git_error` name in the internal API for error-related
functions.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix Linux warnings</title>
<updated>2019-01-09T01:26:14+00:00</updated>
<author>
<name>lhchavez</name>
<email>lhchavez@lhchavez.com</email>
</author>
<published>2019-01-09T01:26:14+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=8b5995283c387114235be9b270899d9646935c46'/>
<id>8b5995283c387114235be9b270899d9646935c46</id>
<content type='text'>
This change fixes -Wmaybe-uninitialized and -Wdeprecated-declarations
warnings on Linux builds
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change fixes -Wmaybe-uninitialized and -Wdeprecated-declarations
warnings on Linux builds
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #4847 from noahp/noahp/null-arg-fixes</title>
<updated>2018-11-18T23:15:56+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2018-11-18T23:15:56+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=646a94be5f01001e09796d03d5f6c077b21b9532'/>
<id>646a94be5f01001e09796d03d5f6c077b21b9532</id>
<content type='text'>
tests: 🌀 address two null argument instances</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
tests: 🌀 address two null argument instances</pre>
</div>
</content>
</entry>
<entry>
<title>tests: address two null argument instances</title>
<updated>2018-11-13T13:22:25+00:00</updated>
<author>
<name>Noah Pendleton</name>
<email>2538614+noahp@users.noreply.github.com</email>
</author>
<published>2018-11-13T13:22:25+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=f127ce3505e308788dd12dcda9b18dc208da1220'/>
<id>f127ce3505e308788dd12dcda9b18dc208da1220</id>
<content type='text'>
Handle two null argument cases that occur in the unit tests.
One is in library code, the other is in test code.

Detected by running unit tests with undefined behavior sanitizer:
```bash
 # build
mkdir build &amp;&amp; cd build
cmake -DBUILD_CLAR=ON -DCMAKE_C_FLAGS="-fsanitize=address \
-fsanitize=undefined -fstack-usage -static-libasan" ..
cmake --build .

 # run with asan
ASAN_OPTIONS="allocator_may_return_null=1" ./libgit2_clar
...
............../libgit2/src/apply.c:316:3: runtime error: null pointer \
passed as argument 1, which is declared to never be null
...................../libgit2/tests/apply/fromfile.c:46:3: runtime \
error: null pointer passed as argument 1, which is declared to never be null
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Handle two null argument cases that occur in the unit tests.
One is in library code, the other is in test code.

Detected by running unit tests with undefined behavior sanitizer:
```bash
 # build
mkdir build &amp;&amp; cd build
cmake -DBUILD_CLAR=ON -DCMAKE_C_FLAGS="-fsanitize=address \
-fsanitize=undefined -fstack-usage -static-libasan" ..
cmake --build .

 # run with asan
ASAN_OPTIONS="allocator_may_return_null=1" ./libgit2_clar
...
............../libgit2/src/apply.c:316:3: runtime error: null pointer \
passed as argument 1, which is declared to never be null
...................../libgit2/tests/apply/fromfile.c:46:3: runtime \
error: null pointer passed as argument 1, which is declared to never be null
```
</pre>
</div>
</content>
</entry>
</feed>
