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
diff --git a/adb_auth_client.c b/adb_auth_client.c
index f8d7306..8409c63 100644
--- a/adb_auth_client.c
+++ b/adb_auth_client.c
@@ -57,7 +57,7 @@
char *sep;
int ret;
- f = fopen(file, "r");
+ f = fopen(file, "re");
if (!f) {
D("Can't open '%s'\n", file);
return;
@@ -126,7 +126,7 @@
FILE *f;
int ret;
- f = fopen("/dev/urandom", "r");
+ f = fopen("/dev/urandom", "re");
if (!f)
return 0;
@@ -257,6 +257,7 @@
D("Failed to get adbd socket\n");
return;
}
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
ret = listen(fd, 4);
if (ret < 0) {