<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/libgit2.git/src/patch_parse.c, branch v1.3.0</title>
<subtitle>github.com: libgit2/libgit2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/'/>
<entry>
<title>patch: use GIT_ASSERT</title>
<updated>2020-11-27T11:09:20+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2020-04-05T17:27:51+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=1a724625e76d9127cf03fb780a924650345f7f60'/>
<id>1a724625e76d9127cf03fb780a924650345f7f60</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #5620 from dlax/parse-patch-add-delete-no-index</title>
<updated>2020-10-04T17:04:01+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2020-10-04T17:04:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=a94fedc11334b23e864824ef33156a660b10022d'/>
<id>a94fedc11334b23e864824ef33156a660b10022d</id>
<content type='text'>
patch_parse: handle absence of "index" header for new/deleted cases</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
patch_parse: handle absence of "index" header for new/deleted cases</pre>
</div>
</content>
</entry>
<entry>
<title>patch_parse: silence maybe-uninitialized warning</title>
<updated>2020-09-18T08:38:45+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-09-18T08:38:45+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=37ae00799395637a37c306b8d1c41ae08f41acda'/>
<id>37ae00799395637a37c306b8d1c41ae08f41acda</id>
<content type='text'>
When building libgit2 with the release build type, then GCC complains
about mode being potentially uninitialized. While this seems to be a
false positive, let's silence this warning by zero-initializing the
mode.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When building libgit2 with the release build type, then GCC complains
about mode being potentially uninitialized. While this seems to be a
false positive, let's silence this warning by zero-initializing the
mode.
</pre>
</div>
</content>
</entry>
<entry>
<title>patch_parse: handle absence of "index" header for new/deleted cases</title>
<updated>2020-08-29T14:54:15+00:00</updated>
<author>
<name>Denis Laxalde</name>
<email>denis@laxalde.org</email>
</author>
<published>2020-08-29T14:46:47+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=74293ea04a21f35151f0be095baf7bd3b3fd339c'/>
<id>74293ea04a21f35151f0be095baf7bd3b3fd339c</id>
<content type='text'>
This follows up on 11de594f85479e4804b07dc4f7b33cfe9212bea0 which added
support for parsing patches without extended headers (the "index
&lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;" line); issue #5267.

We now allow transition from "file mode" state to "path" state directly
if there is no "index", which will happen for patches adding or deleting
files as demonstrated in added test case.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This follows up on 11de594f85479e4804b07dc4f7b33cfe9212bea0 which added
support for parsing patches without extended headers (the "index
&lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;" line); issue #5267.

We now allow transition from "file mode" state to "path" state directly
if there is no "index", which will happen for patches adding or deleting
files as demonstrated in added test case.
</pre>
</div>
</content>
</entry>
<entry>
<title>tree-wide: mark local functions as static</title>
<updated>2020-06-09T12:57:06+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-06-08T10:40:47+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=a6c9e0b367c4882ab0f8e78bd0ad4ab2904ac377'/>
<id>a6c9e0b367c4882ab0f8e78bd0ad4ab2904ac377</id>
<content type='text'>
We've accumulated quite some functions which are never used outside of
their respective code unit, but which are lacking the `static` keyword.
Add it to reduce their linkage scope and allow the compiler to optimize
better.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We've accumulated quite some functions which are never used outside of
their respective code unit, but which are lacking the `static` keyword.
Add it to reduce their linkage scope and allow the compiler to optimize
better.
</pre>
</div>
</content>
</entry>
<entry>
<title>patch: correctly handle mode changes for renames</title>
<updated>2020-03-26T13:21:35+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-03-26T13:16:41+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=5f47cb48d388279f92d339a5a791040254ee4d1c'/>
<id>5f47cb48d388279f92d339a5a791040254ee4d1c</id>
<content type='text'>
When generating a patch for a renamed file whose mode bits have changed
in addition to the rename, then we currently fail to parse the generated
patch. Furthermore, when generating a diff we output mode bits after the
similarity metric, which is different to how upstream git handles it.

Fix both issues by adding another state transition that allows
similarity indices after mode changes and by printing mode changes
before the similarity index.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When generating a patch for a renamed file whose mode bits have changed
in addition to the rename, then we currently fail to parse the generated
patch. Furthermore, when generating a diff we output mode bits after the
similarity metric, which is different to how upstream git handles it.

Fix both issues by adding another state transition that allows
similarity indices after mode changes and by printing mode changes
before the similarity index.
</pre>
</div>
</content>
</entry>
<entry>
<title>patch_parse: fix undefined behaviour due to arithmetic on NULL pointers</title>
<updated>2019-12-13T12:22:56+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2019-12-13T12:18:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=c6f9ad73e25f2abb1c25d50795b0b571305d43a4'/>
<id>c6f9ad73e25f2abb1c25d50795b0b571305d43a4</id>
<content type='text'>
Doing arithmetic with NULL pointers is undefined behaviour in the C
standard. We do so regardless when parsing patches, as we happily add a
potential prefix length to prefixed paths. While this works out just
fine as the prefix length is always equal to zero in these cases, thus
resulting in another NULL pointer, it still is undefined behaviour and
was pointed out to us by OSSfuzz.

Fix the issue by checking whether paths are NULL, avoiding the
arithmetic if they are.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Doing arithmetic with NULL pointers is undefined behaviour in the C
standard. We do so regardless when parsing patches, as we happily add a
potential prefix length to prefixed paths. While this works out just
fine as the prefix length is always equal to zero in these cases, thus
resulting in another NULL pointer, it still is undefined behaviour and
was pointed out to us by OSSfuzz.

Fix the issue by checking whether paths are NULL, avoiding the
arithmetic if they are.
</pre>
</div>
</content>
</entry>
<entry>
<title>patch_parse: fix out-of-bounds reads caused by integer underflow</title>
<updated>2019-11-28T14:26:36+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2019-11-28T14:26:36+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=33e6c40276dec95caa8120387622daf71265e143'/>
<id>33e6c40276dec95caa8120387622daf71265e143</id>
<content type='text'>
The patch format for binary files is a simple Base85 encoding with a
length byte as prefix that encodes the current line's length. For each
line, we thus check whether the line's actual length matches its
expected length in order to not faultily apply a truncated patch. This
also acts as a check to verify that we're not reading outside of the
line's string:

	if (encoded_len &gt; ctx-&gt;parse_ctx.line_len - 1) {
		error = git_parse_err(...);
		goto done;
	}

There is the possibility for an integer underflow, though. Given a line
with a single prefix byte, only, `line_len` will be zero when reaching
this check. As a result, subtracting one from that will result in an
integer underflow, causing us to assume that there's a wealth of bytes
available later on. Naturally, this may result in an out-of-bounds read.

Fix the issue by checking both `encoded_len` and `line_len` for a
non-zero value. The binary format doesn't make use of zero-length lines
anyway, so we need to know that there are both encoded bytes and
remaining characters available at all.

This patch also adds a test that works based on the last error message.
Checking error messages is usually too tightly coupled, but in fact
parsing the patch failed even before the change. Thus the only
possibility is to use e.g. Valgrind, but that'd result in us not
catching issues when run without Valgrind. As a result, using the error
message is considered a viable tradeoff as we know that we didn't start
decoding Base85 in the first place.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The patch format for binary files is a simple Base85 encoding with a
length byte as prefix that encodes the current line's length. For each
line, we thus check whether the line's actual length matches its
expected length in order to not faultily apply a truncated patch. This
also acts as a check to verify that we're not reading outside of the
line's string:

	if (encoded_len &gt; ctx-&gt;parse_ctx.line_len - 1) {
		error = git_parse_err(...);
		goto done;
	}

There is the possibility for an integer underflow, though. Given a line
with a single prefix byte, only, `line_len` will be zero when reaching
this check. As a result, subtracting one from that will result in an
integer underflow, causing us to assume that there's a wealth of bytes
available later on. Naturally, this may result in an out-of-bounds read.

Fix the issue by checking both `encoded_len` and `line_len` for a
non-zero value. The binary format doesn't make use of zero-length lines
anyway, so we need to know that there are both encoded bytes and
remaining characters available at all.

This patch also adds a test that works based on the last error message.
Checking error messages is usually too tightly coupled, but in fact
parsing the patch failed even before the change. Thus the only
possibility is to use e.g. Valgrind, but that'd result in us not
catching issues when run without Valgrind. As a result, using the error
message is considered a viable tradeoff as we know that we didn't start
decoding Base85 in the first place.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #5306 from herrerog/patchid</title>
<updated>2019-11-28T13:41:58+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2019-11-28T13:41:58+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=fb439c975a2de33f5b0c317f3fdea49dc94b27dc'/>
<id>fb439c975a2de33f5b0c317f3fdea49dc94b27dc</id>
<content type='text'>
diff: complete support for git patchid</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
diff: complete support for git patchid</pre>
</div>
</content>
</entry>
<entry>
<title>odb: use `git_object_size_t` for object size</title>
<updated>2019-11-22T04:14:13+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-06-23T15:42:14+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=fefefd1d39420095631987e503402f8ee6956163'/>
<id>fefefd1d39420095631987e503402f8ee6956163</id>
<content type='text'>
Instead of using a signed type (`off_t`) use a new `git_object_size_t`
for the sizes of objects.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of using a signed type (`off_t`) use a new `git_object_size_t`
for the sizes of objects.
</pre>
</div>
</content>
</entry>
</feed>
