<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/pack.h, branch v2.13.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.13.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.13.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-03-24T19:34:07Z</updated>
<entry>
<title>pack.h: define largest possible encoded object size</title>
<updated>2017-03-24T19:34:07Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-03-24T17:26:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2c5e2865cc3dfc053e71510415f479e165119d04'/>
<id>urn:sha1:2c5e2865cc3dfc053e71510415f479e165119d04</id>
<content type='text'>
Several callers use fixed buffers for storing the pack
object header, and they've picked 10 as a magic number. This
is reasonable, since it handles objects up to 2^67. But
let's give them a constant so it's clear that the number
isn't pulled out of thin air.

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>encode_in_pack_object_header: respect output buffer length</title>
<updated>2017-03-24T19:34:07Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-03-24T17:26:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7202a6fa8773fdcf3f374625def3c15276250b67'/>
<id>urn:sha1:7202a6fa8773fdcf3f374625def3c15276250b67</id>
<content type='text'>
The encode_in_pack_object_header() writes a variable-length
header to an output buffer, but it doesn't actually know
long the buffer is. At first glance, this looks like it
might be possible to overflow.

In practice, this is probably impossible. The smallest
buffer we use is 10 bytes, which would hold the header for
an object up to 2^67 bytes. Obviously we're not likely to
see such an object, but we might worry that an object could
lie about its size (causing us to overflow before we realize
it does not actually have that many bytes). But the argument
is passed as a uintmax_t. Even on systems that have __int128
available, uintmax_t is typically restricted to 64-bit by
the ABI.

So it's unlikely that a system exists where this could be
exploited. Still, it's easy enough to use a normal out/len
pair and make sure we don't write too far. That protects the
hypothetical 128-bit system, makes it harder for callers to
accidentally specify a too-small buffer, and makes the
resulting code easier to audit.

Note that the one caller in fast-import tried to catch such
a case, but did so _after_ the call (at which point we'd
have already overflowed!). This check can now go away.

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>fsck: use streaming interface for large blobs in pack</title>
<updated>2016-07-13T16:15:29Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-07-13T15:44:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ec9d224903053e045d99c36149703501098b021c'/>
<id>urn:sha1:ec9d224903053e045d99c36149703501098b021c</id>
<content type='text'>
For blobs, we want to make sure the on-disk data is not corrupted
(i.e. can be inflated and produce the expected SHA-1). Blob content is
opaque, there's nothing else inside to check for.

For really large blobs, we may want to avoid unpacking the entire blob
in memory, just to check whether it produces the same SHA-1. On 32-bit
systems, we may not have enough virtual address space for such memory
allocation. And even on 64-bit where it's not a problem, allocating a
lot more memory could result in kicking other parts of systems to swap
file, generating lots of I/O and slowing everything down.

For this particular operation, not unpacking the blob and letting
check_sha1_signature, which supports streaming interface, do the job
is sufficient. check_sha1_signature() is not shown in the diff,
unfortunately. But if will be called when "data_valid &amp;&amp; !data" is
false.

We will call the callback function "fn" with NULL as "data". The only
callback of this function is fsck_obj_buffer(), which does not touch
"data" at all if it's a blob.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>finish_tmp_packfile():use strbuf for pathname construction</title>
<updated>2014-03-03T20:15:10Z</updated>
<author>
<name>Sun He</name>
<email>sunheehnus@gmail.com</email>
</author>
<published>2014-03-03T09:24:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5889271114a25b6750bb6137784ae5a93df22b39'/>
<id>urn:sha1:5889271114a25b6750bb6137784ae5a93df22b39</id>
<content type='text'>
The old version fixes a maximum length on the buffer, which could be a problem
if one is not certain of the length of get_object_directory().
Using strbuf can avoid the protential bug.

Helped-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Sun He &lt;sunheehnus@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pack-objects: name pack files after trailer hash</title>
<updated>2013-12-05T23:40:11Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2013-12-05T20:28:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1190a1acf800acdcfd7569f87ac1560e2d077414'/>
<id>urn:sha1:1190a1acf800acdcfd7569f87ac1560e2d077414</id>
<content type='text'>
Our current scheme for naming packfiles is to calculate the
sha1 hash of the sorted list of objects contained in the
packfile. This gives us a unique name, so we are reasonably
sure that two packs with the same name will contain the same
objects.

It does not, however, tell us that two such packs have the
exact same bytes. This makes things awkward if we repack the
same set of objects. Due to run-to-run variations, the bytes
may not be identical (e.g., changed zlib or git versions,
different source object reuse due to new packs in the
repository, or even different deltas due to races during a
multi-threaded delta search).

In theory, this could be helpful to a program that cares
that the packfile contains a certain set of objects, but
does not care about the particular representation. In
practice, no part of git makes use of that, and in many
cases it is potentially harmful. For example, if a dumb http
client fetches the .idx file, it must be sure to get the
exact .pack that matches it. Similarly, a partial transfer
of a .pack file cannot be safely resumed, as the actual
bytes may have changed.  This could also affect a local
client which opened the .idx and .pack files, closes the
.pack file (due to memory or file descriptor limits), and
then re-opens a changed packfile.

In all of these cases, git can detect the problem, as we
have the sha1 of the bytes themselves in the pack trailer
(which we verify on transfer), and the .idx file references
the trailer from the matching packfile. But it would be
simpler and more efficient to actually get the correct
bytes, rather than noticing the problem and having to
restart the operation.

This patch simply uses the pack trailer sha1 as the pack
name. It should be similarly unique, but covers the exact
representation of the objects. Other parts of git should not
care, as the pack name is returned by pack-objects and is
essentially opaque.

One test needs to be updated, because it actually corrupts a
pack and expects that re-packing the corrupted bytes will
use the same name. It won't anymore, but we can easily just
use the name that pack-objects hands back.

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 'jc/stream-to-pack'</title>
<updated>2011-12-17T06:33:40Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-12-17T06:33:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=48b303675aa238c209e527feadcbb7ba1c025c97'/>
<id>urn:sha1:48b303675aa238c209e527feadcbb7ba1c025c97</id>
<content type='text'>
* jc/stream-to-pack:
  bulk-checkin: replace fast-import based implementation
  csum-file: introduce sha1file_checkpoint
  finish_tmp_packfile(): a helper function
  create_tmp_packfile(): a helper function
  write_pack_header(): a helper function

Conflicts:
	pack.h
</content>
</entry>
<entry>
<title>Merge branch 'jc/index-pack-reject-dups'</title>
<updated>2011-12-05T23:13:42Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-12-05T23:13:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=33fba9c64e305c64b4d6f4c31f02c1dd7e8fbfa8'/>
<id>urn:sha1:33fba9c64e305c64b4d6f4c31f02c1dd7e8fbfa8</id>
<content type='text'>
* jc/index-pack-reject-dups:
  receive-pack, fetch-pack: reject bogus pack that records objects twice
</content>
</entry>
<entry>
<title>receive-pack, fetch-pack: reject bogus pack that records objects twice</title>
<updated>2011-11-17T06:05:21Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-11-17T06:04:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=68be2fea50e7a34c0e5f9fdf6adb9040c8df197f'/>
<id>urn:sha1:68be2fea50e7a34c0e5f9fdf6adb9040c8df197f</id>
<content type='text'>
When receive-pack &amp; fetch-pack are run and store the pack obtained over
the wire to a local repository, they internally run the index-pack command
with the --strict option. Make sure that we reject incoming packfile that
records objects twice to avoid spreading such a damage.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsck: print progress</title>
<updated>2011-11-07T04:31:28Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2011-11-07T02:59:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e49f22f07881dffc04f8f09d4ad4e4a65b85b09'/>
<id>urn:sha1:1e49f22f07881dffc04f8f09d4ad4e4a65b85b09</id>
<content type='text'>
fsck is usually a long process and it would be nice if it prints
progress from time to time.

Progress meter is not printed when --verbose is given because
--verbose prints a lot, there's no need for "alive" indicator.
Progress meter may provide "% complete" information but it would
be lost anyway in the flood of text.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsck: avoid reading every object twice</title>
<updated>2011-11-07T04:31:28Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2011-11-07T02:59:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c9486eb04dd99fc00df3e68f9b908f9ad7ff9728'/>
<id>urn:sha1:c9486eb04dd99fc00df3e68f9b908f9ad7ff9728</id>
<content type='text'>
During verify_pack() all objects are read for SHA-1 check. Then
fsck_sha1() is called on every object, which read the object again
(fsck_sha1 -&gt; parse_object -&gt; read_sha1_file).

Avoid reading an object twice, do fsck_sha1 while we have an object
uncompressed data in verify_pack.

On git.git, with this patch I got:

$ /usr/bin/time ./git fsck &gt;/dev/null
98.97user 0.90system 1:40.01elapsed 99%CPU (0avgtext+0avgdata 616624maxresident)k
0inputs+0outputs (0major+194186minor)pagefaults 0swaps

Without it:

$ /usr/bin/time ./git fsck &gt;/dev/null
231.23user 2.35system 3:53.82elapsed 99%CPU (0avgtext+0avgdata 636688maxresident)k
0inputs+0outputs (0major+461629minor)pagefaults 0swaps

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
