summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2016-11-19 09:09:16 -0800
committerNick Kralevich <nnk@google.com>2016-11-19 09:11:40 -0800
commitb95c60c78d3a58d04439530c5a0e9197a40cb87b (patch)
tree7a0e8fc560647f6d186ed5e5e0ef56de894ed6cf /server/TetherController.cpp
parent03f1db5be3b6a223cb0fc884c5f5c02611a7ba14 (diff)
TetherController.cpp: add O_CLOEXEC
Don't leak open file descriptors across execs to netd's children. This can occur in the unlikely but theoretically possible event that one thread is in writeToFile() and another thread happens to call exec(). Test: device boots with no obvious problems. Change-Id: Iabd8eee46bf94d70894ca46e58484ccb8241513a
Diffstat (limited to 'server/TetherController.cpp')
-rw-r--r--server/TetherController.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 6617c6a5..7bf4a925 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -46,7 +46,7 @@ const char IPV6_FORWARDING_PROC_FILE[] = "/proc/sys/net/ipv6/conf/all/forwarding
const char SEPARATOR[] = "|";
bool writeToFile(const char* filename, const char* value) {
- int fd = open(filename, O_WRONLY);
+ int fd = open(filename, O_WRONLY | O_CLOEXEC);
if (fd < 0) {
ALOGE("Failed to open %s: %s", filename, strerror(errno));
return false;