summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rebecca Schultz Zavin <rebecca@android.com> 2009-02-13 16:34:38 -0800
committer Rebecca Schultz Zavin <rebecca@android.com> 2009-02-13 16:34:38 -0800
commit360211f7feff8472e082ed5a0675a0b37da74ce5 (patch)
tree06a39198bfc9aa98b008f53af76d4ce70bd2b94d
parent9417399000f5b6f276b69bf99f35a4a87ef1bcd9 (diff)
Need to dup file descriptor when reading from the binder for native handles
When reading a native handle that has passed through the binder, the fds have to be duped to prevent them from getting closed when the binder object is destructed. Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
-rw-r--r--libs/utils/Parcel.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/libs/utils/Parcel.cpp b/libs/utils/Parcel.cpp
index 0eba0b07c8..2962b25aea 100644
--- a/libs/utils/Parcel.cpp
+++ b/libs/utils/Parcel.cpp
@@ -945,14 +945,13 @@ native_handle* Parcel::readNativeHandle(native_handle* (*alloc)(void*, int, int)
return 0;
}
}
-
for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
- h->data[i] = readFileDescriptor();
+ h->data[i] = dup(readFileDescriptor());
if (h->data[i] < 0) err = BAD_VALUE;
}
-
+
err = read(h->data + numFds, sizeof(int)*numInts);
-
+
if (err != NO_ERROR) {
if (alloc == 0) {
free(h);