Loading services/core/jni/com_android_server_security_VerityUtils.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedPrimitiveArray.h> #include <nativehelper/ScopedUtfChars.h> #include "jni.h" #include <utils/Log.h> Loading Loading @@ -73,9 +74,11 @@ namespace android { namespace { int enableFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath, jbyteArray signature) { const char* path = env->GetStringUTFChars(filePath, nullptr); ::android::base::unique_fd rfd(open(path, O_RDONLY | O_CLOEXEC)); env->ReleaseStringUTFChars(filePath, path); ScopedUtfChars path(env, filePath); if (path.c_str() == nullptr) { return EINVAL; } ::android::base::unique_fd rfd(open(path.c_str(), O_RDONLY | O_CLOEXEC)); if (rfd.get() < 0) { return errno; } Loading Loading @@ -106,9 +109,11 @@ int measureFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath) { fsverity_digest *data = reinterpret_cast<fsverity_digest *>(&bytes); data->digest_size = kSha256Bytes; // the only input/output parameter const char* path = env->GetStringUTFChars(filePath, nullptr); ::android::base::unique_fd rfd(open(path, O_RDONLY | O_CLOEXEC)); env->ReleaseStringUTFChars(filePath, path); ScopedUtfChars path(env, filePath); if (path.c_str() == nullptr) { return EINVAL; } ::android::base::unique_fd rfd(open(path.c_str(), O_RDONLY | O_CLOEXEC)); if (rfd.get() < 0) { return errno; } Loading Loading
services/core/jni/com_android_server_security_VerityUtils.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedPrimitiveArray.h> #include <nativehelper/ScopedUtfChars.h> #include "jni.h" #include <utils/Log.h> Loading Loading @@ -73,9 +74,11 @@ namespace android { namespace { int enableFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath, jbyteArray signature) { const char* path = env->GetStringUTFChars(filePath, nullptr); ::android::base::unique_fd rfd(open(path, O_RDONLY | O_CLOEXEC)); env->ReleaseStringUTFChars(filePath, path); ScopedUtfChars path(env, filePath); if (path.c_str() == nullptr) { return EINVAL; } ::android::base::unique_fd rfd(open(path.c_str(), O_RDONLY | O_CLOEXEC)); if (rfd.get() < 0) { return errno; } Loading Loading @@ -106,9 +109,11 @@ int measureFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath) { fsverity_digest *data = reinterpret_cast<fsverity_digest *>(&bytes); data->digest_size = kSha256Bytes; // the only input/output parameter const char* path = env->GetStringUTFChars(filePath, nullptr); ::android::base::unique_fd rfd(open(path, O_RDONLY | O_CLOEXEC)); env->ReleaseStringUTFChars(filePath, path); ScopedUtfChars path(env, filePath); if (path.c_str() == nullptr) { return EINVAL; } ::android::base::unique_fd rfd(open(path.c_str(), O_RDONLY | O_CLOEXEC)); if (rfd.get() < 0) { return errno; } Loading