<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/lockfile.c, branch v2.0.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.0.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.0.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2013-07-07T17:29:28Z</updated>
<entry>
<title>lockfile: fix buffer overflow in path handling</title>
<updated>2013-07-07T17:29:28Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2013-07-06T19:48:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2fbd4f92fa0d6d59d01cf1b9c800d428cd95143d'/>
<id>urn:sha1:2fbd4f92fa0d6d59d01cf1b9c800d428cd95143d</id>
<content type='text'>
The path of the file to be locked is held in lock_file::filename,
which is a fixed-length buffer of length PATH_MAX.  This buffer is
also (temporarily) used to hold the path of the lock file, which is
the path of the file being locked plus ".lock".  Because of this, the
path of the file being locked must be less than (PATH_MAX - 5)
characters long (5 chars are needed for ".lock" and one character for
the NUL terminator).

On entry into lock_file(), the path length was only verified to be
less than PATH_MAX characters, not less than (PATH_MAX - 5)
characters.

When and if resolve_symlink() is called, then that function is
correctly told to treat the buffer as (PATH_MAX - 5) characters long.
This part is correct.  However:

* If LOCK_NODEREF was specified, then resolve_symlink() is never
  called.

* If resolve_symlink() is called but the path is not a symlink, then
  the length check is never applied.

So it is possible for a path with length (PATH_MAX - 5 &lt;= len &lt;
PATH_MAX) to make it through the checks.  When ".lock" is strcat()ted
to such a path, the lock_file::filename buffer is overflowed.

Fix the problem by adding a check when entering lock_file() that the
original path is less than (PATH_MAX - 5) characters.

[jc: with independent development by Peff]

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Name make_*_path functions more accurately</title>
<updated>2011-03-17T23:08:30Z</updated>
<author>
<name>Carlos Martín Nieto</name>
<email>cmn@elego.de</email>
</author>
<published>2011-03-17T11:26:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e2a57aac8a8a2b786739a5a93ea9dcfd2f0fd0e2'/>
<id>urn:sha1:e2a57aac8a8a2b786739a5a93ea9dcfd2f0fd0e2</id>
<content type='text'>
Rename the make_*_path functions so it's clearer what they do, in
particlar make clear what the differnce between make_absolute_path and
make_nonrelative_path is by renaming them real_path and absolute_path
respectively. make_relative_path has an understandable name and is
renamed to relative_path to maintain the name convention.

The function calls have been replaced 1-to-1 in their usage.

Signed-off-by: Carlos Martín Nieto &lt;cmn@elego.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>lockfile: show absolute filename in unable_to_lock_message</title>
<updated>2010-01-12T23:48:24Z</updated>
<author>
<name>Matthieu Moy</name>
<email>Matthieu.Moy@imag.fr</email>
</author>
<published>2010-01-07T14:54:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a8c37a0e011d67e3192834a0fffe17452ea57a08'/>
<id>urn:sha1:a8c37a0e011d67e3192834a0fffe17452ea57a08</id>
<content type='text'>
When calling a git command from a subdirectory and a file locking fails,
the user will get a path relative to the root of the worktree, which is
invalid from the place where the command is ran. Make it easy for the
user to know which file it is.

Signed-off-by: Matthieu Moy &lt;Matthieu.Moy@imag.fr&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git branch -D: give a better error message when lockfile creation fails</title>
<updated>2009-09-29T15:14:47Z</updated>
<author>
<name>Miklos Vajna</name>
<email>vmiklos@frugalware.org</email>
</author>
<published>2009-09-26T23:15:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1b018fd9be290fd6a70ce3093ab1dc1abce74e00'/>
<id>urn:sha1:1b018fd9be290fd6a70ce3093ab1dc1abce74e00</id>
<content type='text'>
Previously the old error message just told the user that it was not
possible to delete the ref from the packed-refs file. Give instructions
on how to resolve the problem.

Signed-off-by: Miklos Vajna &lt;vmiklos@frugalware.org&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Shawn O. Pearce &lt;spearce@spearce.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ar/unlink-err'</title>
<updated>2009-05-18T16:01:06Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2009-05-18T16:01:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=36587681b4743c980e4e74a342dc5ec105314d08'/>
<id>urn:sha1:36587681b4743c980e4e74a342dc5ec105314d08</id>
<content type='text'>
* ar/unlink-err:
  print unlink(2) errno in copy_or_link_directory
  replace direct calls to unlink(2) with unlink_or_warn
  Introduce an unlink(2) wrapper which gives warning if unlink failed
</content>
</entry>
<entry>
<title>Fix a bunch of pointer declarations (codestyle)</title>
<updated>2009-05-01T22:17:31Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2009-05-01T09:06:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4b25d091ba53c758fae0096b8c0662371857b9d9'/>
<id>urn:sha1:4b25d091ba53c758fae0096b8c0662371857b9d9</id>
<content type='text'>
Essentially; s/type* /type */ as per the coding guidelines.

Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>replace direct calls to unlink(2) with unlink_or_warn</title>
<updated>2009-04-30T01:37:41Z</updated>
<author>
<name>Alex Riesen</name>
<email>raa.lkml@gmail.com</email>
</author>
<published>2009-04-29T21:22:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=691f1a28bf57618d8b44a193b1d28013c858aba6'/>
<id>urn:sha1:691f1a28bf57618d8b44a193b1d28013c858aba6</id>
<content type='text'>
This helps to notice when something's going wrong, especially on
systems which lock open files.

I used the following criteria when selecting the code for replacement:
- it was already printing a warning for the unlink failures
- it is in a function which already printing something or is
  called from such a function
- it is in a static function, returning void and the function is only
  called from a builtin main function (cmd_)
- it is in a function which handles emergency exit (signal handlers)
- it is in a function which is obvously cleaning up the lockfiles

Signed-off-by: Alex Riesen &lt;raa.lkml@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Make the 'lock file' exists error more informative</title>
<updated>2009-03-05T04:35:19Z</updated>
<author>
<name>John Tapsell</name>
<email>johnflux@gmail.com</email>
</author>
<published>2009-03-04T15:00:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bdfd739dac4c109ce360d38d0572d8717a46e795'/>
<id>urn:sha1:bdfd739dac4c109ce360d38d0572d8717a46e795</id>
<content type='text'>
It looks like someone did 90% of the work, then forgot to actually use
the function in one place.

Also the helper function did not use the correct variable.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'maint'</title>
<updated>2009-02-20T07:44:07Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2009-02-20T07:44:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8c5b85ce87d15e4db37a6408f03b0eb71dde080e'/>
<id>urn:sha1:8c5b85ce87d15e4db37a6408f03b0eb71dde080e</id>
<content type='text'>
* maint:
  More friendly message when locking the index fails.
  Document git blame --reverse.
  Documentation: Note file formats send-email accepts
</content>
</entry>
<entry>
<title>More friendly message when locking the index fails.</title>
<updated>2009-02-20T07:22:57Z</updated>
<author>
<name>Matthieu Moy</name>
<email>Matthieu.Moy@imag.fr</email>
</author>
<published>2009-02-19T12:54:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e43a6fd3e94888d76779ad79fb568ed180e5fcdf'/>
<id>urn:sha1:e43a6fd3e94888d76779ad79fb568ed180e5fcdf</id>
<content type='text'>
Just saying that index.lock exists doesn't tell the user _what_ to do
to fix the problem. We should give an indication that it's normally
safe to delete index.lock after making sure git isn't running here.

Signed-off-by: Matthieu Moy &lt;Matthieu.Moy@imag.fr&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
