<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/dir.c, branch v2.22.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.22.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.22.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2019-06-13T18:28:53Z</updated>
<entry>
<title>cleanup: fix possible overflow errors in binary search, part 2</title>
<updated>2019-06-13T18:28:53Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2019-06-13T17:51:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=568a05c5ecb8e3a01fcb90d0f81857f49ef2add8'/>
<id>urn:sha1:568a05c5ecb8e3a01fcb90d0f81857f49ef2add8</id>
<content type='text'>
Calculating the sum of two array indexes to find the midpoint between
them can overflow, i.e. code like this is unsafe for big arrays:

	mid = (first + last) &gt;&gt; 1;

Make sure the intermediate value stays within the boundaries instead,
like this:

	mid = first + ((last - first) &gt;&gt; 1);

The loop condition of the binary search makes sure that 'last' is
always greater than 'first', so this is safe as long as 'first' is
not negative.  And that can be verified easily using the pre-context
of each change, except for name-hash.c, so add an assertion to that
effect there.

The unsafe calculations were found with:

	git grep '(.*+.*) *&gt;&gt; *1'

This is a continuation of 19716b21a4 (cleanup: fix possible overflow
errors in binary search, 2017-10-08).

Signed-off-by: Rene 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 'jk/untracked-cache-more-fixes'</title>
<updated>2019-05-08T15:37:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-08T15:37:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5b5def9a99030ecf2b62163ea7856f91cd8f292c'/>
<id>urn:sha1:5b5def9a99030ecf2b62163ea7856f91cd8f292c</id>
<content type='text'>
Code clean-up.

* jk/untracked-cache-more-fixes:
  untracked-cache: simplify parsing by dropping "len"
  untracked-cache: simplify parsing by dropping "next"
  untracked-cache: be defensive about missing NULs in index
</content>
</entry>
<entry>
<title>Merge branch 'nd/sha1-name-c-wo-the-repository'</title>
<updated>2019-05-08T15:37:25Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-08T15:37:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0b179f3175d1a152b1d22ce8352efda34b258ce2'/>
<id>urn:sha1:0b179f3175d1a152b1d22ce8352efda34b258ce2</id>
<content type='text'>
Further code clean-up to allow the lowest level of name-to-object
mapping layer to work with a passed-in repository other than the
default one.

* nd/sha1-name-c-wo-the-repository: (34 commits)
  sha1-name.c: remove the_repo from get_oid_mb()
  sha1-name.c: remove the_repo from other get_oid_*
  sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_name
  submodule-config.c: use repo_get_oid for reading .gitmodules
  sha1-name.c: add repo_get_oid()
  sha1-name.c: remove the_repo from get_oid_with_context_1()
  sha1-name.c: remove the_repo from resolve_relative_path()
  sha1-name.c: remove the_repo from diagnose_invalid_index_path()
  sha1-name.c: remove the_repo from handle_one_ref()
  sha1-name.c: remove the_repo from get_oid_1()
  sha1-name.c: remove the_repo from get_oid_basic()
  sha1-name.c: remove the_repo from get_describe_name()
  sha1-name.c: remove the_repo from get_oid_oneline()
  sha1-name.c: add repo_interpret_branch_name()
  sha1-name.c: remove the_repo from interpret_branch_mark()
  sha1-name.c: remove the_repo from interpret_nth_prior_checkout()
  sha1-name.c: remove the_repo from get_short_oid()
  sha1-name.c: add repo_for_each_abbrev()
  sha1-name.c: store and use repo in struct disambiguate_state
  sha1-name.c: add repo_find_unique_abbrev_r()
  ...
</content>
</entry>
<entry>
<title>Merge branch 'km/empty-repo-is-still-a-repo'</title>
<updated>2019-05-08T15:37:23Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-08T15:37:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4ab701b2eec46ab5cbfe8c9732897e5d100184d8'/>
<id>urn:sha1:4ab701b2eec46ab5cbfe8c9732897e5d100184d8</id>
<content type='text'>
Running "git add" on a repository created inside the current
repository is an explicit indication that the user wants to add it
as a submodule, but when the HEAD of the inner repository is on an
unborn branch, it cannot be added as a submodule.  Worse, the files
in its working tree can be added as if they are a part of the outer
repository, which is not what the user wants.  These problems are
being addressed.

* km/empty-repo-is-still-a-repo:
  add: error appropriately on repository with no commits
  dir: do not traverse repositories with no commits
  submodule: refuse to add repository with no commits
</content>
</entry>
<entry>
<title>Merge branch 'js/untracked-cache-allocfix'</title>
<updated>2019-04-25T07:41:22Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-25T07:41:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0830eac14cf6d0f0392a3a87d96f916e79dc4319'/>
<id>urn:sha1:0830eac14cf6d0f0392a3a87d96f916e79dc4319</id>
<content type='text'>
An underallocation in the code to read the untracked cache
extension has been corrected.

* js/untracked-cache-allocfix:
  untracked cache: fix off-by-one
</content>
</entry>
<entry>
<title>Merge branch 'bc/hash-transition-16'</title>
<updated>2019-04-25T07:41:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-25T07:41:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d4e568b2a31d7b2fe45dac9165bb077b570fc96a'/>
<id>urn:sha1:d4e568b2a31d7b2fe45dac9165bb077b570fc96a</id>
<content type='text'>
Conversion from unsigned char[20] to struct object_id continues.

* bc/hash-transition-16: (35 commits)
  gitweb: make hash size independent
  Git.pm: make hash size independent
  read-cache: read data in a hash-independent way
  dir: make untracked cache extension hash size independent
  builtin/difftool: use parse_oid_hex
  refspec: make hash size independent
  archive: convert struct archiver_args to object_id
  builtin/get-tar-commit-id: make hash size independent
  get-tar-commit-id: parse comment record
  hash: add a function to lookup hash algorithm by length
  remote-curl: make hash size independent
  http: replace sha1_to_hex
  http: compute hash of downloaded objects using the_hash_algo
  http: replace hard-coded constant with the_hash_algo
  http-walker: replace sha1_to_hex
  http-push: remove remaining uses of sha1_to_hex
  http-backend: allow 64-character hex names
  http-push: convert to use the_hash_algo
  builtin/pull: make hash-size independent
  builtin/am: make hash size independent
  ...
</content>
</entry>
<entry>
<title>untracked-cache: simplify parsing by dropping "len"</title>
<updated>2019-04-19T05:33:21Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-04-18T21:18:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=08bf354de71a806bad319ec236740ac698b58a5b'/>
<id>urn:sha1:08bf354de71a806bad319ec236740ac698b58a5b</id>
<content type='text'>
The code which parses untracked-cache extensions from disk keeps a "len"
variable, which is the size of the string we are parsing. But since we
now have an "end of string" variable, we can just use that to get the
length when we need it. This eliminates the need to keep "len" up to
date (and removes the possibility of any errors where "len" and "eos"
get out of sync).

As a bonus, it means we are not storing a string length in an "int",
which is a potential source of overflows (though in this case it seems
fairly unlikely for that to cause any memory problems).

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>untracked-cache: simplify parsing by dropping "next"</title>
<updated>2019-04-19T05:30:58Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-04-18T21:17:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b511d6d569ce8baee888700ebd12f82d991a5250'/>
<id>urn:sha1:b511d6d569ce8baee888700ebd12f82d991a5250</id>
<content type='text'>
When we parse an on-disk untracked cache, we have two pointers, "data"
and "next". As we parse, we point "next" to the end of an element, and
then later update "data" to match.

But we actually don't need two pointers. Each parsing step can just
update "data" directly from other variables we hold (and we don't have
to worry about bailing in an intermediate state, since any parsing
failure causes us to immediately discard "data" and return).

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>untracked-cache: be defensive about missing NULs in index</title>
<updated>2019-04-19T05:27:07Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-04-18T21:17:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c6909f9959d394db8b76f08a6e59e5a82dade07a'/>
<id>urn:sha1:c6909f9959d394db8b76f08a6e59e5a82dade07a</id>
<content type='text'>
The on-disk format for the untracked-cache extension contains
NUL-terminated filenames. We parse these from the mmap'd file using
string functions like strlen(). This works fine in the normal case, but
if we see a malformed or corrupted index, we might read off the end of
our mmap.

Instead, let's use memchr() to find the trailing NUL within the bytes we
know are available, and return an error if it's missing.

Note that we can further simplify by folding another range check into
our conditional. After we find the end of the string, we set "next" to
the byte after the string and treat it as an error if there are no such
bytes left. That saves us from having to do a range check at the
beginning of each subsequent string (and works because there is always
data after each string). We can do both range checks together by
checking "!eos" (we didn't find a NUL) and "eos == end" (it was on the
last available byte, meaning there's nothing after). This replaces the
existing "next &gt; end" checks.

Note also that the decode_varint() calls have a similar problem (we
don't even pass them "end"; they just keep parsing). These are probably
OK in practice since varints have a finite length (we stop parsing when
we'd overflow a uintmax_t), so the worst case is that we'd overflow into
reading the trailing bytes of the index.

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>sha1-name.c: remove the_repo from diagnose_invalid_index_path()</title>
<updated>2019-04-16T09:56:53Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-04-16T09:33:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0488481e795e3cb683944e54bb0670a1c6e8b477'/>
<id>urn:sha1:0488481e795e3cb683944e54bb0670a1c6e8b477</id>
<content type='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>
</feed>
