diff options
author | Nick Kralevich <nnk@google.com> | 2014-07-18 20:57:35 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2014-07-18 20:57:35 -0700 |
commit | fe8d7f4f2e775d46d61f7c2d29a4e852434984da (patch) | |
tree | b9a2a4ca15704c600a827e9ee1fee069677bead5 /adb/file_sync_service.c | |
parent | 400c381835b9eed533c67a062d88af5365590f7f (diff) | |
download | system_core-fe8d7f4f2e775d46d61f7c2d29a4e852434984da.tar.gz system_core-fe8d7f4f2e775d46d61f7c2d29a4e852434984da.tar.bz2 system_core-fe8d7f4f2e775d46d61f7c2d29a4e852434984da.zip |
adb: set O_CLOEXEC on lots of file descriptors
Too many leaking FDs.
Fixes bug: https://code.google.com/p/android/issues/detail?id=65857
(and more)
Change-Id: I67d8683244e54288a8105f6f65ee40abe2378d7e
Diffstat (limited to 'adb/file_sync_service.c')
-rw-r--r-- | adb/file_sync_service.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/adb/file_sync_service.c b/adb/file_sync_service.c index e6f64bb1b..793385851 100644 --- a/adb/file_sync_service.c +++ b/adb/file_sync_service.c @@ -183,18 +183,18 @@ static int handle_send_file(int s, char *path, uid_t uid, unsigned int timestamp = 0; int fd; - fd = adb_open_mode(path, O_WRONLY | O_CREAT | O_EXCL, mode); + fd = adb_open_mode(path, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, mode); if(fd < 0 && errno == ENOENT) { if(mkdirs(path) != 0) { if(fail_errno(s)) return -1; fd = -1; } else { - fd = adb_open_mode(path, O_WRONLY | O_CREAT | O_EXCL, mode); + fd = adb_open_mode(path, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, mode); } } if(fd < 0 && errno == EEXIST) { - fd = adb_open_mode(path, O_WRONLY, mode); + fd = adb_open_mode(path, O_WRONLY | O_CLOEXEC, mode); } if(fd < 0) { if(fail_errno(s)) @@ -388,7 +388,7 @@ static int do_recv(int s, const char *path, char *buffer) syncmsg msg; int fd, r; - fd = adb_open(path, O_RDONLY); + fd = adb_open(path, O_RDONLY | O_CLOEXEC); if(fd < 0) { if(fail_errno(s)) return -1; return 0; |