From 59ca44715a317ee48afed34ca7ef1ab710ba5046 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 29 Jun 2009 21:19:28 -0400 Subject: [PATCH] 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" --- shlibs/uuid/src/gen_uuid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shlibs/uuid/src/gen_uuid.c b/shlibs/uuid/src/gen_uuid.c index 8497ac67..32a6453b 100644 --- a/shlibs/uuid/src/gen_uuid.c +++ b/shlibs/uuid/src/gen_uuid.c @@ -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); + } } /* -- 2.39.5