Re: [PATCH] be paranoid about closed stdin/stdout/stderr
- From
Paolo Bonzini <bonzini@gnu.org>
- Date
- Aug 27, 2008, 08:20 UTC
- Message-ID
- <48B50E47.3010402@gnu.org>
- In-Reply-To
- <48B4F5C4.9020404@viscovery.net>
Show 5 quoted lines
>> Busybox. But it runs setuid, as Steven pointed out. > > I straced tee (it was the only tool I found that opens files for writing > without also opening some for reading). If one of 0,1,2 is closed, it > *does* dup() the fd that it is going to write.
To be precise, it does a blind "dup2 (fd, 3)" and goes on with file descriptor 3.
open("foo", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 0 fcntl64(0, F_DUPFD, 3) = 3 close(0) = 0
Paolo