From: Theodore Ts'o Date: Tue, 30 Jun 2009 01:19:28 +0000 (-0400) Subject: libuuid: Make sure fd's 0, 1, and 2 are valid before exec'ing uuidd X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59ca44715a317ee48afed34ca7ef1ab710ba5046;p=util-linux 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/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); + } } /*