Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f11cb156 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix JNI misuse during fs-verity setup"

parents e0d74cdf 561e2861
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "VerityUtils"

#include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedPrimitiveArray.h>
#include "jni.h"
#include <utils/Log.h>

@@ -78,6 +79,10 @@ int enableFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath, jbyteArra
    if (rfd.get() < 0) {
      return errno;
    }
    ScopedByteArrayRO signature_bytes(env, signature);
    if (signature_bytes.get() == nullptr) {
        return EINVAL;
    }

    fsverity_enable_arg arg = {};
    arg.version = 1;
@@ -85,8 +90,8 @@ int enableFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath, jbyteArra
    arg.block_size = 4096;
    arg.salt_size = 0;
    arg.salt_ptr = reinterpret_cast<uintptr_t>(nullptr);
    arg.sig_size = env->GetArrayLength(signature);
    arg.sig_ptr = reinterpret_cast<uintptr_t>(signature);
    arg.sig_size = signature_bytes.size();
    arg.sig_ptr = reinterpret_cast<uintptr_t>(signature_bytes.get());

    if (ioctl(rfd.get(), FS_IOC_ENABLE_VERITY, &arg) < 0) {
      return errno;