diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-06-29 19:06:45 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-06-29 19:06:45 -0400 |
commit | e8b9466fc9d4aec66476f1bc7a48436da02ab557 (patch) | |
tree | 83566be798ca00f1d4c5f08ec55e4575c598cca8 /lib | |
parent | d9206a341452845c7a9da9e84d54520859f0eca3 (diff) | |
download | e2fsprogs-e8b9466fc9d4aec66476f1bc7a48436da02ab557.tar.gz |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/uuid/gen_uuid.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index b7a12eed..aa313efe 100644 --- a/lib/uuid/gen_uuid.c +++ b/lib/uuid/gen_uuid.c @@ -455,8 +455,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); + } } |