Merge branch 'tr/protect-low-3-fds'

When "git" is spawned in such a way that any of the low 3 file
descriptors is closed, our first open() may yield file descriptor 2,
and writing error message to it would screw things up in a big way.

* tr/protect-low-3-fds:
  git: ensure 0/1/2 are open in main()
  daemon/shell: refactor redirection of 0/1/2 from /dev/null
This commit is contained in:
Junio C Hamano
2013-07-22 11:23:35 -07:00
5 changed files with 24 additions and 21 deletions

7
git.c
View File

@ -525,6 +525,13 @@ int main(int argc, char **av)
if (!cmd)
cmd = "git-help";
/*
* Always open file descriptors 0/1/2 to avoid clobbering files
* in die(). It also avoids messing up when the pipes are dup'ed
* onto stdin/stdout/stderr in the child processes we spawn.
*/
sanitize_stdfds();
git_setup_gettext();
/*