<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/git.git/diff-delta.c, branch v2.26.0-rc2</title>
<subtitle>Git
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v2.26.0-rc2</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v2.26.0-rc2'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/'/>
<updated>2019-09-06T18:03:39Z</updated>
<entry>
<title>diff-delta: set size out-parameter to 0 for NULL delta</title>
<updated>2019-09-06T18:03:39Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-09-05T22:53:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=e4b369069e4a7630233a045784d0b1e2425b0a05'/>
<id>urn:sha1:e4b369069e4a7630233a045784d0b1e2425b0a05</id>
<content type='text'>
When we cannot generate a delta, we return NULL but leave delta_size
untouched. This is generally OK, as callers rely on NULL to decide if
the output is usable or not. But it can confuse compilers; in
particular, gcc 9.2.1 with "-flto -O3" complains in fast-import's
store_object() that delta_len may be used uninitialized.

Let's change the diff-delta code to set the size explicitly to 0 for a
NULL return. That silences the compiler and makes it easier to reason
about the result.

Reported-by: Stephan Beyer &lt;s-beyer@gmx.net&gt;
Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'mk/diff-delta-avoid-large-offset'</title>
<updated>2017-09-28T05:47:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-09-28T05:47:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=fdbe2ac1983c1224ce40b465b22e44d7e22de6c4'/>
<id>urn:sha1:fdbe2ac1983c1224ce40b465b22e44d7e22de6c4</id>
<content type='text'>
The delta format used in the packfile cannot reference data at
offset larger than what can be expressed in 4-byte, but the
generator for the data failed to make sure the offset does not
overflow.  This has been corrected.

* mk/diff-delta-avoid-large-offset:
  diff-delta: do not allow delta offset truncation
</content>
</entry>
<entry>
<title>diff-delta: do not allow delta offset truncation</title>
<updated>2017-08-11T22:25:40Z</updated>
<author>
<name>Martin Koegler</name>
<email>martin.koegler@chello.at</email>
</author>
<published>2017-08-10T18:13:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=fed1ef9550d528dffa8891e8b2f49b486c7985bc'/>
<id>urn:sha1:fed1ef9550d528dffa8891e8b2f49b486c7985bc</id>
<content type='text'>
Prevent generating delta offsets beyond 4G, as the xdelta used in
the pack format cannot represent such large offset.

Signed-off-by: Martin Koegler &lt;martin.koegler@chello.at&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-delta: fix encoding size that would not fit in "unsigned int"</title>
<updated>2017-08-10T20:55:22Z</updated>
<author>
<name>Martin Koegler</name>
<email>martin.koegler@chello.at</email>
</author>
<published>2017-08-10T07:01:01Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=3f0a67a1f68d79f102ac11a8b6e7a72dc86be613'/>
<id>urn:sha1:3f0a67a1f68d79f102ac11a8b6e7a72dc86be613</id>
<content type='text'>
The current delta code produces incorrect pack objects for files &gt; 4GB,
because the size is copied from size_t field to "unsigned int" variables
during the encoding process.

Signed-off-by: Martin Koegler &lt;martin.koegler@chello.at&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>create_delta_index: simplify condition always evaluating to true</title>
<updated>2013-08-18T19:56:23Z</updated>
<author>
<name>Stefan Beller</name>
<email>stefanbeller@googlemail.com</email>
</author>
<published>2013-08-16T21:22:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=f7466e94375b3be27f229c78873f0acf8301c0a5'/>
<id>urn:sha1:f7466e94375b3be27f229c78873f0acf8301c0a5</id>
<content type='text'>
The code sequence  ' (1u &lt;&lt; i) &lt; hsize &amp;&amp; i &lt; 31 ' is a multi step
process, whose first step requires that 'i' is already less that 31,
otherwise the result (1u &lt;&lt; i)  is undefined (and  'undef_val &lt; hsize'
can therefore be assumed to be 'false'), and so the later test  i &lt; 31
can always be optimized away as dead code ('i' is already less than 31,
or the short circuit 'and' applies).

So we need to get rid of that code. One way would be to exchange the
order of the conditions, so the expression 'i &lt; 31 &amp;&amp; (1u &lt;&lt; i) &lt; hsize'
would remove that optimized unstable code already.

However when checking the previous lines in that function, we can deduce
that 'hsize' must always be smaller than (1u&lt;&lt;31), since 506049c7df2c6
(fix &gt;4GiB source delta assertion failure), because 'entries' is
capped at an upper bound of 0xfffffffeU, so 'hsize' contains a maximum
value of 0x3fffffff, which is smaller than (1u&lt;&lt;31), so the value of
'i' will never be larger than 31 and we can remove that condition
entirely.

Signed-off-by: Stefan Beller &lt;stefanbeller@googlemail.com&gt;
Acked-by: Nicolas Pitre &lt;nico@fluxnic.net&gt;
Acked-by: Philip Oakley &lt;philipoakley@iee.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fix &gt;4GiB source delta assertion failure</title>
<updated>2010-08-22T06:53:26Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>nico@fluxnic.net</email>
</author>
<published>2010-08-21T05:00:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=506049c7df2c68f1db5a4bae502cfb1af0a73048'/>
<id>urn:sha1:506049c7df2c68f1db5a4bae502cfb1af0a73048</id>
<content type='text'>
When people try insane things such as delta-compressing 4GiB files, they
get this assertion:

diff-delta.c:285: create_delta_index: Assertion `packed_entry - (struct index_entry *)mem == entries' failed.

This happens because:

1) the 'entries' variable is an unsigned int

2) it is assigned with entries = (bufsize - 1) / RABIN_WINDOW
   (that itself is not a problem unless bufsize &gt; 4G * RABIN_WINDOW)

3) the buffer is indexed from top to bottom starting at
   "data = buffer + entries * RABIN_WINDOW" and the multiplication
   here does indeed overflows, making the resulting top of the buffer
   much lower than expected.

This makes the number of actually produced index entries smaller than
what was computed initially, hence the assertion.

Furthermore, the current delta encoding format cannot represent offsets
into a reference buffer with more than 32 bits anyway.  So let's just
limit the number of entries to what the delta format can encode.

Reported-by: Ilari Liusvaara &lt;ilari.liusvaara@elisanet.fi&gt;
Signed-off-by: Nicolas Pitre &lt;nico@fluxnic.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Nicolas Pitre has a new email address</title>
<updated>2009-09-14T09:23:36Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>nico@fluxnic.net</email>
</author>
<published>2009-09-14T06:41:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=03aa8ff3be3b35522b2e378651e65e0e86778018'/>
<id>urn:sha1:03aa8ff3be3b35522b2e378651e65e0e86778018</id>
<content type='text'>
Due to problems at cam.org, my nico@cam.org email address is no longer
valid.  From now on, nico@fluxnic.net should be used instead.

Signed-off-by: Nicolas Pitre &lt;nico@fluxnic.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fix style of a few comments in diff-delta.c</title>
<updated>2007-12-18T23:22:28Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>nico@cam.org</email>
</author>
<published>2007-12-18T15:15:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=ce85b053d827e2f7c2ee2683cc09393e4768cc22'/>
<id>urn:sha1:ce85b053d827e2f7c2ee2683cc09393e4768cc22</id>
<content type='text'>
Signed-off-by: Nicolas Pitre &lt;nico@cam.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Fix segfault in diff-delta.c when FLEX_ARRAY is 1</title>
<updated>2007-12-18T05:59:26Z</updated>
<author>
<name>Pierre Habouzit</name>
<email>madcoder@debian.org</email>
</author>
<published>2007-12-18T01:39:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=f9c5a80cdf2265f2df7712fad9f1fb7ef68b4768'/>
<id>urn:sha1:f9c5a80cdf2265f2df7712fad9f1fb7ef68b4768</id>
<content type='text'>
aka don't do pointer arithmetics on structs that have a FLEX_ARRAY member,
or you'll end up believing your array is 1 cell off its real address.

Signed-off-by: Pierre Habouzit &lt;madcoder@debian.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-delta.c: Rationalize culling of hash buckets</title>
<updated>2007-09-10T00:16:49Z</updated>
<author>
<name>David Kastrup</name>
<email>dak@gnu.org</email>
</author>
<published>2007-09-08T21:25:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=02e665ce491296245f474dafdc02d47a6c8afa86'/>
<id>urn:sha1:02e665ce491296245f474dafdc02d47a6c8afa86</id>
<content type='text'>
The previous hash bucket culling resulted in a somewhat unpredictable
number of hash bucket entries in the order of magnitude of HASH_LIMIT.

Replace this with a Bresenham-like algorithm leaving us with exactly
HASH_LIMIT entries by uniform culling.

Signed-off-by: David Kastrup &lt;dak@gnu.org&gt;
Acked-by: Nicolas Pitre &lt;nico@cam.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
