From e9ffc3a5f9414cdc4c3e5b8bf25fefe4f01cf725 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Mon, 17 Oct 2011 22:27:35 +0200 Subject: Fix CVE-2011-4029: File permission change vulnerability. Use fchmod() to change permissions of the lock file instead of chmod(), thus avoid the race that can be exploited to set a symbolic link to any file or directory in the system. Signed-off-by: Matthieu Herrb Reviewed-by: Alan Coopersmith (cherry picked from commit b67581cf825940fdf52bf2e0af4330e695d724a4) --- os/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/utils.c b/os/utils.c index 575998ff9..de6476a8b 100644 --- a/os/utils.c +++ b/os/utils.c @@ -306,7 +306,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* -- cgit v1.2.1