From 07f1c1db854e28eee715bff44d5a75fc30650462 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Mon, 14 Jan 2019 13:42:22 -0800 Subject: [PATCH] Bitmap.cpp: replace dup() with fcntl(F_DUPFD_CLOEXEC) Replace calls to dup() with fcntl(F_DUPFD_CLOEXEC). The only difference between the two is that O_CLOEXEC is set on the newly duped file descriptor. This helps address file descriptor leaks crossing an exec() boundary. Test: compiles and boots Change-Id: I0c3b1baa49677a8e4831e1880e2d0ab38e08c6f4 --- core/jni/android/graphics/Bitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index b085bc93f5dde..b6fbb0ae287bd 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -1095,7 +1095,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { #endif // Dup the file descriptor so we can keep a reference to it after the Parcel // is disposed. - int dupFd = dup(blob.fd()); + int dupFd = fcntl(blob.fd(), F_DUPFD_CLOEXEC, 0); if (dupFd < 0) { ALOGE("Error allocating dup fd. Error:%d", errno); blob.release();