diff options
author | Elliott Hughes <enh@google.com> | 2013-08-02 16:02:34 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-08-02 16:24:08 -0700 |
commit | ff7ff110d17428732a97c37bf31f7f49d194f638 (patch) | |
tree | 43fb00c47bf1967b0fc8b60def46d78bf45fa36d /vm/Native.cpp | |
parent | 813a3a2d1c295266299425cac35a817b06f026e3 (diff) | |
download | android_dalvik-ff7ff110d17428732a97c37bf31f7f49d194f638.tar.gz android_dalvik-ff7ff110d17428732a97c37bf31f7f49d194f638.tar.bz2 android_dalvik-ff7ff110d17428732a97c37bf31f7f49d194f638.zip |
Check JNI versions handed to JNI and JII functions.
Bug: https://code.google.com/p/android/issues/detail?id=58012
Change-Id: I7b062564573107df54f9e8d71df0e1583d83d421
Diffstat (limited to 'vm/Native.cpp')
-rw-r--r-- | vm/Native.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/vm/Native.cpp b/vm/Native.cpp index 8892c2a34..a024db884 100644 --- a/vm/Native.cpp +++ b/vm/Native.cpp @@ -438,11 +438,12 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader, dvmChangeStatus(self, oldStatus); self->classLoaderOverride = prevOverride; - if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4 && - version != JNI_VERSION_1_6) - { - ALOGW("JNI_OnLoad returned bad version (%d) in %s %p", - version, pathName, classLoader); + if (version == JNI_ERR) { + *detail = strdup(StringPrintf("JNI_ERR returned from JNI_OnLoad in \"%s\"", + pathName).c_str()); + } else if (dvmIsBadJniVersion(version)) { + *detail = strdup(StringPrintf("Bad JNI version returned from JNI_OnLoad in \"%s\": %d", + pathName, version).c_str()); /* * It's unwise to call dlclose() here, but we can mark it * as bad and ensure that future load attempts will fail. @@ -453,10 +454,10 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader, * unregister them, but that doesn't seem worthwhile. */ result = false; - } else { - if (gDvm.verboseJni) { - ALOGI("[Returned from JNI_OnLoad for \"%s\"]", pathName); - } + } + if (gDvm.verboseJni) { + ALOGI("[Returned %s from JNI_OnLoad for \"%s\"]", + (result ? "successfully" : "failure"), pathName); } } |