<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/git.git/read-cache.c, branch v1.7.7.4</title>
<subtitle>Git
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v1.7.7.4</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v1.7.7.4'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/'/>
<updated>2011-10-26T21:35:16Z</updated>
<entry>
<title>read-cache.c: fix index memory allocation</title>
<updated>2011-10-26T21:35:16Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2011-10-24T01:01:27Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=8f41c07f90da5e314cbc428f1e3e936563f7f39d'/>
<id>urn:sha1:8f41c07f90da5e314cbc428f1e3e936563f7f39d</id>
<content type='text'>
estimate_cache_size() tries to guess how much memory is needed for the
in-memory representation of an index file.  It does that by using the
file size, the number of entries and the difference of the sizes of the
on-disk and in-memory structs -- without having to check the length of
the name of each entry, which varies for each entry, but their sums are
the same no matter the representation.

Except there can be a difference.  First of all, the size is really
calculated by ce_size and ondisk_ce_size based on offsetof(..., name),
not sizeof, which can be different.  And entries are padded with 1 to 8
NULs at the end (after the variable name) to make their total length a
multiple of eight.

So in order to allocate enough memory to hold the index, change the
delta calculation to be based on offsetof(..., name) and round up to
the next multiple of eight.

On a 32-bit Linux, this delta was used before:

	sizeof(struct cache_entry)        == 72
	sizeof(struct ondisk_cache_entry) == 64
	                                    ---
	                                      8

The actual difference for an entry with a filename length of one was,
however (find the definitions are in cache.h):

	offsetof(struct cache_entry, name)        == 72
	offsetof(struct ondisk_cache_entry, name) == 62

	ce_size        == (72 + 1 + 8) &amp; ~7 == 80
	ondisk_ce_size == (62 + 1 + 8) &amp; ~7 == 64
	                                      ---
	                                       16

So eight bytes less had been allocated for such entries.  The new
formula yields the correct delta:

	(72 - 62 + 7) &amp; ~7 == 16

Reported-by: John Hsing &lt;tsyj2007@gmail.com&gt;
Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'maint'</title>
<updated>2011-08-25T23:00:07Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-08-25T23:00:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=1952e102b702b977d6bdfcee7cb48b843cb92049'/>
<id>urn:sha1:1952e102b702b977d6bdfcee7cb48b843cb92049</id>
<content type='text'>
* maint:
  whitespace: have SP on both sides of an assignment "="
  update-ref: whitespace fix
</content>
</entry>
<entry>
<title>whitespace: have SP on both sides of an assignment "="</title>
<updated>2011-08-25T21:47:07Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-08-25T21:46:52Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=cd2b8ae983a277fb3f3c2b2c6747b0a075af1421'/>
<id>urn:sha1:cd2b8ae983a277fb3f3c2b2c6747b0a075af1421</id>
<content type='text'>
I've deliberately excluded the borrowed code in compat/nedmalloc
directory.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ef/maint-win-verify-path'</title>
<updated>2011-06-30T00:09:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-06-30T00:09:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=033c2dc4364042b9e6dbd44e82e1974f78a72567'/>
<id>urn:sha1:033c2dc4364042b9e6dbd44e82e1974f78a72567</id>
<content type='text'>
* ef/maint-win-verify-path:
  verify_dotfile(): do not assume '/' is the path seperator
  verify_path(): simplify check at the directory boundary
  verify_path: consider dos drive prefix
  real_path: do not assume '/' is the path seperator
  A Windows path starting with a backslash is absolute
</content>
</entry>
<entry>
<title>verify_dotfile(): do not assume '/' is the path seperator</title>
<updated>2011-06-08T23:34:38Z</updated>
<author>
<name>Theo Niessink</name>
<email>theo@taletn.com</email>
</author>
<published>2011-06-08T12:04:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=e0f530ff8afbd252170f57e70a8609a83a7cabe1'/>
<id>urn:sha1:e0f530ff8afbd252170f57e70a8609a83a7cabe1</id>
<content type='text'>
verify_dotfile() currently assumes that the path seperator is '/', but on
Windows it can also be '\\', so use is_dir_sep() instead.

Signed-off-by: Theo Niessink &lt;theo@taletn.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>verify_path(): simplify check at the directory boundary</title>
<updated>2011-06-07T19:22:51Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-06-07T03:49:06Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=3bdf09c7f555d553b4fee00c00c760b546812d4f'/>
<id>urn:sha1:3bdf09c7f555d553b4fee00c00c760b546812d4f</id>
<content type='text'>
We simply want to say "At a directory boundary, be careful with a name
that begins with a dot, forbid a name that ends with the boundary
character or has duplicated bounadry characters".

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>verify_path: consider dos drive prefix</title>
<updated>2011-05-27T17:59:18Z</updated>
<author>
<name>Erik Faye-Lund</name>
<email>kusmabite@gmail.com</email>
</author>
<published>2011-05-27T16:00:40Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=56948cb6aa8189e3b77c700119d179172e0f8c4a'/>
<id>urn:sha1:56948cb6aa8189e3b77c700119d179172e0f8c4a</id>
<content type='text'>
If someone manage to create a repo with a 'C:' entry in the
root-tree, files can be written outside of the working-dir. This
opens up a can-of-worms of exploits.

Fix it by explicitly checking for a dos drive prefix when verifying
a paht. While we're at it, make sure that paths beginning with '\' is
considered absolute as well.

Noticed-by: Theo Niessink &lt;theo@taletn.com&gt;
Signed-off-by: Erik Faye-Lund &lt;kusmabite@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>index_fd(): turn write_object and format_check arguments into one flag</title>
<updated>2011-05-09T18:58:19Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-05-08T08:47:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=c4ce46fc7ac1b59372aa935e641ca15b12359f5b'/>
<id>urn:sha1:c4ce46fc7ac1b59372aa935e641ca15b12359f5b</id>
<content type='text'>
The "format_check" parameter tucked after the existing parameters is too
ugly an afterthought to live in any reasonable API.

Combine it with the other boolean parameter "write_object" into a single
"flags" parameter.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jc/index-update-if-able' into maint</title>
<updated>2011-04-03T19:33:05Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-04-03T19:33:05Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=44ec754dc766e38684d9ad4563019378730eea82'/>
<id>urn:sha1:44ec754dc766e38684d9ad4563019378730eea82</id>
<content type='text'>
* jc/index-update-if-able:
  update $GIT_INDEX_FILE when there are racily clean entries
  diff/status: refactor opportunistic index update
</content>
</entry>
<entry>
<title>Merge branch 'jc/index-update-if-able'</title>
<updated>2011-03-27T03:13:16Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-03-27T03:13:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=149971badc562f4e5ee66c045f40c904fb29eab6'/>
<id>urn:sha1:149971badc562f4e5ee66c045f40c904fb29eab6</id>
<content type='text'>
* jc/index-update-if-able:
  update $GIT_INDEX_FILE when there are racily clean entries
  diff/status: refactor opportunistic index update
</content>
</entry>
</feed>
