summaryrefslogtreecommitdiffstats
path: root/libs/binder
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-09-28 23:19:47 -0400
committerDianne Hackborn <hackbod@google.com>2011-10-03 16:58:41 -0700
commit9ecebbfbf768fd63e9a6c9a09c86d81c7737ee2d (patch)
tree08d24c5413fa49ac6386f8b396f29e297e728fbd /libs/binder
parent8ebf1efd66516340bedbf0d0a19d5e96cc28fa20 (diff)
downloadframeworks_base-9ecebbfbf768fd63e9a6c9a09c86d81c7737ee2d.zip
frameworks_base-9ecebbfbf768fd63e9a6c9a09c86d81c7737ee2d.tar.gz
frameworks_base-9ecebbfbf768fd63e9a6c9a09c86d81c7737ee2d.tar.bz2
Add mechanism for Parcel to not allow FDs to be written to it.
This is to help implement issue #5224703. Change-Id: I026a5890495537d15b57fe61227a640aac806d46
Diffstat (limited to 'libs/binder')
-rw-r--r--libs/binder/Parcel.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index a0fc4d0..8eeab7a 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -399,6 +399,8 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
mDataPos += len;
mDataSize += len;
+ err = NO_ERROR;
+
if (numObjects > 0) {
// grow objects
if (mObjectsCapacity < mObjectsSize + numObjects) {
@@ -430,11 +432,21 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
flat->handle = dup(flat->handle);
flat->cookie = (void*)1;
mHasFds = mFdsKnown = true;
+ if (!mAllowFds) {
+ err = FDS_NOT_ALLOWED;
+ }
}
}
}
- return NO_ERROR;
+ return err;
+}
+
+bool Parcel::setAllowFds(bool allowFds)
+{
+ const bool origValue = mAllowFds;
+ mAllowFds = allowFds;
+ return origValue;
}
bool Parcel::hasFileDescriptors() const
@@ -759,6 +771,9 @@ restart_write:
// remember if it's a file descriptor
if (val.type == BINDER_TYPE_FD) {
+ if (!mAllowFds) {
+ return FDS_NOT_ALLOWED;
+ }
mHasFds = mFdsKnown = true;
}
@@ -1283,6 +1298,7 @@ status_t Parcel::restartWrite(size_t desired)
mNextObjectHint = 0;
mHasFds = false;
mFdsKnown = true;
+ mAllowFds = true;
return NO_ERROR;
}
@@ -1434,6 +1450,7 @@ void Parcel::initState()
mNextObjectHint = 0;
mHasFds = false;
mFdsKnown = true;
+ mAllowFds = true;
mOwner = NULL;
}