OSDN Git Service

Fix double close in NativeLibraryHelper.openApkFd.
authorJosh Gao <jmgao@google.com>
Tue, 17 Jul 2018 22:00:31 +0000 (15:00 -0700)
committerJosh Gao <jmgao@google.com>
Wed, 18 Jul 2018 01:16:17 +0000 (18:16 -0700)
commitb066087d65b720a5c9ac48f64a856284566df82f
tree3b3e6cdd5d10190157da746833786017b65852f0
parent55ce82b1dd1ba337b977d64c8d1a1a0eca13e512
Fix double close in NativeLibraryHelper.openApkFd.

Prior to this patch, we were taking the file descriptor owned by a
ParcelFileDescriptor, and passing it into ZipFileRO::openFd, which
expects to take ownership of the file descriptor, closing it upon
destruction. This leads to a double-close when the ParcelFileDescriptor
tries to close itself. Switch to passing a duped copy of the file
descriptor to ZipFileRO::openFd.

Test: `pm install foo.apk` with fdsan
Change-Id: Ida4ca4a37b82875dc4eef1f37bf2322c422fe038
core/jni/com_android_internal_content_NativeLibraryHelper.cpp