author | Jonathan Nieder <jrnieder@gmail.com> | |
Thu, 13 Jan 2011 02:26:36 +0000 (20:26 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 13 Jan 2011 19:25:32 +0000 (11:25 -0800) | ||
commit | 92fda79ed048d2d37e760e7a1b6055b2fc801ee3 | |
tree | 382f6ef92af09daecc40f37bf9fa4bb634beecea | tree | snapshot |
parent | 3f142468997f9d14d8051a96b2e9db265d41ac0d | commit | diff |
unpack-trees: handle lstat failure for existing directory
When check_leading_path notices no file in the way of the new entry to
be checked out, verify_absent checks whether there is a directory
there or nothing at all. If that lstat call fails (for example due to
ENOMEM), it assumes ENOENT, meaning a directory with untracked files
would be clobbered in that case.
Check errno after calling lstat, and for conditions other than ENOENT,
just error out.
This is a theoretical race condition. lstat has to succeed moments
before it fails for there to be trouble.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
When check_leading_path notices no file in the way of the new entry to
be checked out, verify_absent checks whether there is a directory
there or nothing at all. If that lstat call fails (for example due to
ENOMEM), it assumes ENOENT, meaning a directory with untracked files
would be clobbered in that case.
Check errno after calling lstat, and for conditions other than ENOENT,
just error out.
This is a theoretical race condition. lstat has to succeed moments
before it fails for there to be trouble.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c | diff | blob | history |