From: Theodore Ts'o Date: Mon, 29 Jun 2009 23:06:45 +0000 (-0400) Subject: libuuid: Make sure fd's 0, 1, and 2 are valid before exec'ing uuidd X-Git-Tag: v1.41.8~31 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e8b9466fc9d4aec66476f1bc7a48436da02ab557;p=tools%2Fe2fsprogs.git 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" --- diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index b7a12ee..aa313ef 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); + } }