summaryrefslogtreecommitdiffstats
path: root/libs/binder
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2014-10-07 00:34:57 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-07 00:34:57 +0000
commitf3b5cea662da350684b9fd7a8f486c42e57bee6d (patch)
tree1e4e4aae4de458eee00010ee784196a04819a07e /libs/binder
parentae29ee0a9eea291316248a90799ff28f35defeb6 (diff)
parent366998d87109578eb8c33d2e94d61fe7f189beb8 (diff)
downloadframeworks_native-f3b5cea662da350684b9fd7a8f486c42e57bee6d.zip
frameworks_native-f3b5cea662da350684b9fd7a8f486c42e57bee6d.tar.gz
frameworks_native-f3b5cea662da350684b9fd7a8f486c42e57bee6d.tar.bz2
am 366998d8: am 78639c22: Merge "Parcel: extra validation/debug code for writeDupFileDescriptor" into lmp-dev
* commit '366998d87109578eb8c33d2e94d61fe7f189beb8': Parcel: extra validation/debug code for writeDupFileDescriptor
Diffstat (limited to 'libs/binder')
-rw-r--r--libs/binder/Parcel.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index ba5688c..f61eaca 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -26,6 +26,7 @@
#include <binder/TextOutput.h>
#include <errno.h>
+#include <utils/CallStack.h>
#include <utils/Debug.h>
#include <utils/Log.h>
#include <utils/String8.h>
@@ -767,6 +768,29 @@ status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership)
status_t Parcel::writeDupFileDescriptor(int fd)
{
int dupFd = dup(fd);
+
+ { // Temporary extra debug validation for b/17477219: a Parcel recipient is
+ // getting a positive but invalid fd unexpectedly. Trying to track down
+ // where it's coming from.
+ int dupErrno = dupFd < 0 ? errno : 0;
+ int fdFlags = fcntl(fd, F_GETFD);
+ int fdFlagsErrno = fdFlags == -1 ? errno : 0;
+ int dupFlags = fcntl(dupFd, F_GETFD);
+ int dupFlagsErrno = dupFlags == -1 ? errno : 0;
+ if (dupFd < 0 || fdFlags == -1 || dupFlags == -1) {
+ ALOGE("Parcel::writeDupFileDescriptor failed:\n"
+ " fd=%d flags=%d err=%d(%s)\n"
+ " dupFd=%d dupErr=%d(%s) flags=%d err=%d(%s)",
+ fd, fdFlags, fdFlagsErrno, strerror(fdFlagsErrno),
+ dupFd, dupErrno, strerror(dupErrno),
+ dupFlags, dupFlagsErrno, strerror(dupFlagsErrno));
+ if (fd < 0 || fdFlags == -1) {
+ CallStack(LOG_TAG);
+ }
+ return -errno;
+ }
+ }
+
if (dupFd < 0) {
return -errno;
}
@@ -1297,6 +1321,7 @@ status_t Parcel::read(FlattenableHelperInterface& val) const
oldfd, fds[i], dupErrno, strerror(dupErrno),
oldfd, flags, fcntlErrno, strerror(fcntlErrno),
flat, flat ? flat->type : 0);
+ CallStack(LOG_TAG);
}
}