feat: Add null checks for JNI method arguments
Adds a null pointer check for the origApkPath and cacheApkPath arguments in the enableOpenatHook native method. Previously, passing nullptr to this method would lead to a potential crash. The added checks ensure the function handles invalid input gracefully by logging an error and returning early, thus preventing a potential crash.
This commit is contained in:
parent
4b8da5c255
commit
5bbef84a43
|
|
@ -2,6 +2,8 @@ name: Build CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
merge_group:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -41,7 +43,7 @@ jobs:
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.ccache
|
path: ~/.ccache
|
||||||
key: ${{ runner.os }}-ccache-${{ github.sha }}
|
key: ${{ runner.os }}-ccache-${{ hashFiles('**/src/**/*.cpp', '**/src/**/*.h', '**/CMakeLists.txt') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-ccache-
|
${{ runner.os }}-ccache-
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Created by VIP on 2021/4/25.
|
// Created by VIP on 2021/4/25.
|
||||||
// Update by HSSkyBoy on 2025/9/7
|
// Update by HSSkyBoy on 2025/9/11
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "bypass_sig.h"
|
#include "bypass_sig.h"
|
||||||
|
|
@ -45,8 +45,14 @@ inline static auto __openat_ =
|
||||||
|
|
||||||
LSP_DEF_NATIVE_METHOD(void, SigBypass, enableOpenatHook, jstring origApkPath,
|
LSP_DEF_NATIVE_METHOD(void, SigBypass, enableOpenatHook, jstring origApkPath,
|
||||||
jstring cacheApkPath) {
|
jstring cacheApkPath) {
|
||||||
|
if (origApkPath == nullptr || cacheApkPath == nullptr) {
|
||||||
|
LOGE("Invalid arguments: original or cache path is null.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lsplant::JUTFString str1(env, origApkPath);
|
lsplant::JUTFString str1(env, origApkPath);
|
||||||
lsplant::JUTFString str2(env, cacheApkPath);
|
lsplant::JUTFString str2(env, cacheApkPath);
|
||||||
|
|
||||||
apkPath = str1.get();
|
apkPath = str1.get();
|
||||||
redirectPath = str2.get();
|
redirectPath = str2.get();
|
||||||
|
|
||||||
|
|
@ -56,7 +62,9 @@ inline static auto __openat_ =
|
||||||
void *bk = nullptr;
|
void *bk = nullptr;
|
||||||
return HookInline(t, r, &bk) == 0 ? bk : nullptr;
|
return HookInline(t, r, &bk) == 0 ? bk : nullptr;
|
||||||
},
|
},
|
||||||
.art_symbol_resolver = [](auto symbol) { return GetC()->getSymbAddress(symbol); },
|
.art_symbol_resolver = [](auto symbol) {
|
||||||
|
return GetC()->getSymbAddress(symbol);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!r) {
|
if (!r) {
|
||||||
LOGE("Hook __openat fail");
|
LOGE("Hook __openat fail");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue