1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
From 7a37a81a87d5c78a2e8e90781898d88df9f861af Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Tue, 18 Dec 2012 17:32:04 +0100
Subject: [PATCH] libowfat: 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.
---
io/io_closeonexec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io/io_closeonexec.c b/io/io_closeonexec.c
index b36d636..aad4773 100644
--- a/io/io_closeonexec.c
+++ b/io/io_closeonexec.c
@@ -5,6 +5,6 @@
void io_closeonexec(int64 d) {
#ifndef __MINGW32__
- fcntl(d,F_SETFL,fcntl(d,F_GETFL,0) | FD_CLOEXEC);
+ fcntl(d,F_SETFD,fcntl(d,F_GETFD,0) | FD_CLOEXEC);
#endif
}
--
1.8.1.rc0
|