libuuid: Make sure fd's 0, 1, and 2 are valid before exec'ing uuidd
When closing all of the file descriptors before starting uuidd, make sure file descriptors 0, 1, and 2 are reserved by opening /dev/null. This prevents strange bugs caused by assumptions regarding file descriptors <= 2 as being special. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
6dc9c350bd
commit
59ca44715a
|
@ -461,8 +461,11 @@ static void close_all_fds(void)
|
|||
max = OPEN_MAX;
|
||||
#endif
|
||||
|
||||
for (i=0; i < max; i++)
|
||||
for (i=0; i < max; i++) {
|
||||
close(i);
|
||||
if (i <= 2)
|
||||
open("/dev/null", O_RDWR);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue