Loading libs/binder/OS.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -48,4 +48,14 @@ status_t getRandomBytes(uint8_t* data, size_t size) { return OK; } status_t dupFileDescriptor(int oldFd, int* newFd) { int ret = fcntl(oldFd, F_DUPFD_CLOEXEC, 0); if (ret < 0) { return -errno; } *newFd = ret; return OK; } } // namespace android libs/binder/OS.h +2 −0 Original line number Diff line number Diff line Loading @@ -28,4 +28,6 @@ android::base::Result<void> setNonBlocking(android::base::borrowed_fd fd); status_t getRandomBytes(uint8_t* data, size_t size); status_t dupFileDescriptor(int oldFd, int* newFd); } // namespace android libs/binder/Parcel.cpp +19 −8 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ #include <utils/String8.h> #include <utils/misc.h> #include "OS.h" #include "RpcState.h" #include "Static.h" #include "Utils.h" Loading Loading @@ -1477,9 +1478,9 @@ status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership) { status_t Parcel::writeDupFileDescriptor(int fd) { int dupFd = fcntl(fd, F_DUPFD_CLOEXEC, 0); if (dupFd < 0) { return -errno; int dupFd; if (status_t err = dupFileDescriptor(fd, &dupFd); err != OK) { return err; } status_t err = writeFileDescriptor(dupFd, true /*takeOwnership*/); if (err != OK) { Loading @@ -1496,9 +1497,9 @@ status_t Parcel::writeParcelFileDescriptor(int fd, bool takeOwnership) status_t Parcel::writeDupParcelFileDescriptor(int fd) { int dupFd = fcntl(fd, F_DUPFD_CLOEXEC, 0); if (dupFd < 0) { return -errno; int dupFd; if (status_t err = dupFileDescriptor(fd, &dupFd); err != OK) { return err; } status_t err = writeParcelFileDescriptor(dupFd, true /*takeOwnership*/); if (err != OK) { Loading Loading @@ -2295,7 +2296,12 @@ status_t Parcel::readUniqueFileDescriptor(base::unique_fd* val) const return BAD_TYPE; } val->reset(fcntl(got, F_DUPFD_CLOEXEC, 0)); int dupFd; if (status_t err = dupFileDescriptor(got, &dupFd); err != OK) { return BAD_VALUE; } val->reset(dupFd); if (val->get() < 0) { return BAD_VALUE; Loading @@ -2312,7 +2318,12 @@ status_t Parcel::readUniqueParcelFileDescriptor(base::unique_fd* val) const return BAD_TYPE; } val->reset(fcntl(got, F_DUPFD_CLOEXEC, 0)); int dupFd; if (status_t err = dupFileDescriptor(got, &dupFd); err != OK) { return BAD_VALUE; } val->reset(dupFd); if (val->get() < 0) { return BAD_VALUE; Loading libs/binder/trusty/OS.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -32,4 +32,9 @@ status_t getRandomBytes(uint8_t* data, size_t size) { return res == 1 ? OK : UNKNOWN_ERROR; } status_t dupFileDescriptor(int oldFd, int* newFd) { // TODO: implement separately return INVALID_OPERATION; } } // namespace android libs/binder/trusty/rules.mk +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ MODULE_SRCS := \ $(LIBBINDER_DIR)/IInterface.cpp \ $(LIBBINDER_DIR)/IResultReceiver.cpp \ $(LIBBINDER_DIR)/Parcel.cpp \ $(LIBBINDER_DIR)/ParcelFileDescriptor.cpp \ $(LIBBINDER_DIR)/RpcServer.cpp \ $(LIBBINDER_DIR)/RpcSession.cpp \ $(LIBBINDER_DIR)/RpcState.cpp \ Loading Loading
libs/binder/OS.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -48,4 +48,14 @@ status_t getRandomBytes(uint8_t* data, size_t size) { return OK; } status_t dupFileDescriptor(int oldFd, int* newFd) { int ret = fcntl(oldFd, F_DUPFD_CLOEXEC, 0); if (ret < 0) { return -errno; } *newFd = ret; return OK; } } // namespace android
libs/binder/OS.h +2 −0 Original line number Diff line number Diff line Loading @@ -28,4 +28,6 @@ android::base::Result<void> setNonBlocking(android::base::borrowed_fd fd); status_t getRandomBytes(uint8_t* data, size_t size); status_t dupFileDescriptor(int oldFd, int* newFd); } // namespace android
libs/binder/Parcel.cpp +19 −8 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ #include <utils/String8.h> #include <utils/misc.h> #include "OS.h" #include "RpcState.h" #include "Static.h" #include "Utils.h" Loading Loading @@ -1477,9 +1478,9 @@ status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership) { status_t Parcel::writeDupFileDescriptor(int fd) { int dupFd = fcntl(fd, F_DUPFD_CLOEXEC, 0); if (dupFd < 0) { return -errno; int dupFd; if (status_t err = dupFileDescriptor(fd, &dupFd); err != OK) { return err; } status_t err = writeFileDescriptor(dupFd, true /*takeOwnership*/); if (err != OK) { Loading @@ -1496,9 +1497,9 @@ status_t Parcel::writeParcelFileDescriptor(int fd, bool takeOwnership) status_t Parcel::writeDupParcelFileDescriptor(int fd) { int dupFd = fcntl(fd, F_DUPFD_CLOEXEC, 0); if (dupFd < 0) { return -errno; int dupFd; if (status_t err = dupFileDescriptor(fd, &dupFd); err != OK) { return err; } status_t err = writeParcelFileDescriptor(dupFd, true /*takeOwnership*/); if (err != OK) { Loading Loading @@ -2295,7 +2296,12 @@ status_t Parcel::readUniqueFileDescriptor(base::unique_fd* val) const return BAD_TYPE; } val->reset(fcntl(got, F_DUPFD_CLOEXEC, 0)); int dupFd; if (status_t err = dupFileDescriptor(got, &dupFd); err != OK) { return BAD_VALUE; } val->reset(dupFd); if (val->get() < 0) { return BAD_VALUE; Loading @@ -2312,7 +2318,12 @@ status_t Parcel::readUniqueParcelFileDescriptor(base::unique_fd* val) const return BAD_TYPE; } val->reset(fcntl(got, F_DUPFD_CLOEXEC, 0)); int dupFd; if (status_t err = dupFileDescriptor(got, &dupFd); err != OK) { return BAD_VALUE; } val->reset(dupFd); if (val->get() < 0) { return BAD_VALUE; Loading
libs/binder/trusty/OS.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -32,4 +32,9 @@ status_t getRandomBytes(uint8_t* data, size_t size) { return res == 1 ? OK : UNKNOWN_ERROR; } status_t dupFileDescriptor(int oldFd, int* newFd) { // TODO: implement separately return INVALID_OPERATION; } } // namespace android
libs/binder/trusty/rules.mk +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ MODULE_SRCS := \ $(LIBBINDER_DIR)/IInterface.cpp \ $(LIBBINDER_DIR)/IResultReceiver.cpp \ $(LIBBINDER_DIR)/Parcel.cpp \ $(LIBBINDER_DIR)/ParcelFileDescriptor.cpp \ $(LIBBINDER_DIR)/RpcServer.cpp \ $(LIBBINDER_DIR)/RpcSession.cpp \ $(LIBBINDER_DIR)/RpcState.cpp \ Loading