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 31 32 33 34 35 36 37 38 39 40 41
|
From: Guillem Jover <guillem@hadrons.org>
Date: Tue, 18 Dec 2012 17:25:40 +0100
Subject: 9base: 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.
---
lib9/create.c | 2 +-
lib9/open.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Index: 9base/lib9/create.c
===================================================================
--- 9base.orig/lib9/create.c
+++ 9base/lib9/create.c
@@ -67,7 +67,7 @@ out:
}
}
if(cexec)
- fcntl(fd, F_SETFL, FD_CLOEXEC);
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
if(rclose)
remove(path);
}
Index: 9base/lib9/open.c
===================================================================
--- 9base.orig/lib9/open.c
+++ 9base/lib9/open.c
@@ -54,7 +54,7 @@ p9open(char *name, int mode)
}
}
if(cexec)
- fcntl(fd, F_SETFL, FD_CLOEXEC);
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
if(rclose)
remove(name);
}
|