Your message dated Wed, 19 Dec 2012 09:07:48 +0100
with message-id <[email protected]>
has caused the   report #696250,
regarding freeradius: Sets FD_CLOEXEC incorrectly with F_SETFL instead of 
F_SETFD
to be marked as having been forwarded to the upstream software
author(s) Alan DeKok <[email protected]>

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
696250: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=696250
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
----- Forwarded message from Guillem Jover <[email protected]> -----

Date: Tue, 18 Dec 2012 18:02:56 +0100
From: Guillem Jover <[email protected]>
To: [email protected]
Subject: Bug#696250: freeradius: Sets FD_CLOEXEC incorrectly with F_SETFL
        instead of F_SETFD

Source: freeradius
Version: 2.1.12+dfsg-1.2
Severity: important
Tags: patch
User: [email protected]
Usertags: fcntl-fd-cloexec

Hi!

This package contains code that tries to set the FD_CLOEXEC flag for a
file descriptor, but it does using F_SETFL instead of F_SETFD.

Using that value on F_SETFL is just wrong, and might make the call fail
on some systems, as it's requesting to set an undetermined flag. For
example on GNU/* FD_CLOEXEC has value 1, which matches with O_WRONLY.

This will cause the code to at least leak file descriptors, and at worst
to terminate execution.

Attached a patch fixing this.

Thanks,
Guillem

>From 2597bc6f58e76ba4cd75664b6e8a5f3aa039c8ad Mon Sep 17 00:00:00 2001
From: Guillem Jover <[email protected]>
Date: Tue, 18 Dec 2012 17:45:04 +0100
Subject: [PATCH] freeradious: Set FD_CLOEXEC correctly using F_SETFD not
 F_SETFL

Using that value on F_SETFL is just wrong, and might make the call fail
on some systems, as it's requesting to set an undetermined flag. For
example on GNU/* FD_CLOEXEC has value 1, which matches with O_WRONLY.

This might cause the code to at least leak file descriptors, and at worst
to terminate execution.
---
 src/main/event.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main/event.c b/src/main/event.c
index 5090747..6802d1a 100644
--- a/src/main/event.c
+++ b/src/main/event.c
@@ -3600,12 +3600,14 @@ int radius_event_init(CONF_SECTION *cs, int spawn_flag)
                       strerror(errno));
                exit(1);
        }
-       if (fcntl(self_pipe[0], F_SETFL, O_NONBLOCK | FD_CLOEXEC) < 0) {
+       if (fcntl(self_pipe[0], F_SETFL, O_NONBLOCK) < 0 ||
+           fcntl(self_pipe[0], F_SETFD, FD_CLOEXEC) < 0) {
                radlog(L_ERR, "radiusd: Error setting internal flags: %s",
                       strerror(errno));
                exit(1);
        }
-       if (fcntl(self_pipe[1], F_SETFL, O_NONBLOCK | FD_CLOEXEC) < 0) {
+       if (fcntl(self_pipe[1], F_SETFL, O_NONBLOCK) < 0 ||
+           fcntl(self_pipe[1], F_SETFD, FD_CLOEXEC) < 0) {
                radlog(L_ERR, "radiusd: Error setting internal flags: %s",
                       strerror(errno));
                exit(1);
-- 
1.8.1.rc0



----- End forwarded message -----

--- End Message ---

Reply via email to