Commit 0c681cda authored by topjohnwu's avatar topjohnwu

Check null before dereferencing fds_to_ignore

parent 13ef3058
...@@ -394,15 +394,17 @@ void HookContext::run_modules_pre(const vector<int> &fds) { ...@@ -394,15 +394,17 @@ void HookContext::run_modules_pre(const vector<int> &fds) {
// Add all ignored fd onto whitelist // Add all ignored fd onto whitelist
if (state[APP_SPECIALIZE] && args->fds_to_ignore) { if (state[APP_SPECIALIZE] && args->fds_to_ignore) {
int len = env->GetArrayLength(*args->fds_to_ignore); if (jintArray fdsToIgnore = *args->fds_to_ignore) {
int *arr = env->GetIntArrayElements(*args->fds_to_ignore, nullptr); int len = env->GetArrayLength(fdsToIgnore);
int *arr = env->GetIntArrayElements(fdsToIgnore, nullptr);
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
int fd = arr[i]; int fd = arr[i];
if (fd >= 0 && fd < 1024) { if (fd >= 0 && fd < 1024) {
open_fds[fd] = true; open_fds[fd] = true;
} }
} }
env->ReleaseIntArrayElements(*args->fds_to_ignore, arr, 0); env->ReleaseIntArrayElements(fdsToIgnore, arr, JNI_ABORT);
}
} }
// Close all unrecorded fds // Close all unrecorded fds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment