diff options
author | Jeff Hamilton <jham@android.com> | 2011-04-20 16:23:48 -0500 |
---|---|---|
committer | Jeff Hamilton <jham@android.com> | 2011-04-20 16:23:48 -0500 |
commit | a8d8c1fa5058573c0d9d1305549c4326737db0b8 (patch) | |
tree | 3ab2acf565e2bdf3c56454977b390deafe17d7b2 /jni/com_android_nfc_NativeNfcSecureElement.cpp | |
parent | 7a7f8f8fd82936f0ee005ccfa7ac5c36760ed902 (diff) | |
download | packages_apps_nfc-a8d8c1fa5058573c0d9d1305549c4326737db0b8.zip packages_apps_nfc-a8d8c1fa5058573c0d9d1305549c4326737db0b8.tar.gz packages_apps_nfc-a8d8c1fa5058573c0d9d1305549c4326737db0b8.tar.bz2 |
Avoid reference table overflows when dealing with secure elements.
Bug: 4258601
Change-Id: Ib21892b6efa8e23ea86566ed6f88c2e9d284fa89
Diffstat (limited to 'jni/com_android_nfc_NativeNfcSecureElement.cpp')
-rwxr-xr-x | jni/com_android_nfc_NativeNfcSecureElement.cpp | 76 |
1 files changed, 27 insertions, 49 deletions
diff --git a/jni/com_android_nfc_NativeNfcSecureElement.cpp b/jni/com_android_nfc_NativeNfcSecureElement.cpp index b6e936c..7defeb2 100755 --- a/jni/com_android_nfc_NativeNfcSecureElement.cpp +++ b/jni/com_android_nfc_NativeNfcSecureElement.cpp @@ -122,63 +122,41 @@ static void com_android_nfc_jni_open_secure_element_notification_callback(void * else { LOG_CALLBACK("com_android_nfc_jni_open_secure_element_notification_callback", status); - TRACE("Discovered %d tags", uNofRemoteDev); + TRACE("Discovered %d secure elements", uNofRemoteDev); if(status == NFCSTATUS_MULTIPLE_PROTOCOLS) { TRACE("Multiple Protocol supported\n"); - - TRACE("Secure Element Handle: 0x%08x",psRemoteDevList[1].hTargetDev); - secureElementHandle = psRemoteDevList[1].hTargetDev; - - /* Set type name */ - jintArray techList; - jintArray handleList; - jintArray typeList; - - nfc_jni_get_technology_tree(e, psRemoteDevList,uNofRemoteDev, &techList, - &handleList, &typeList); - // TODO: Should use the "connected" technology, for now use the first - if (e->GetArrayLength(techList) > 0) { - jint* technologies = e->GetIntArrayElements(techList, 0); - SecureElementTech = technologies[0]; - TRACE("Store Secure Element Info\n"); - SecureElementInfo = psRemoteDevList->psRemoteDevInfo; - - TRACE("Discovered secure element: tech=%d", SecureElementTech); - } - else { - LOGE("Discovered secure element, but could not resolve tech"); - status = NFCSTATUS_FAILED; - } - + secureElementHandle = psRemoteDevList[1].hTargetDev; } else { - TRACE("Secure Element Handle: 0x%08x",psRemoteDevList->hTargetDev); - secureElementHandle = psRemoteDevList->hTargetDev; - - /* Set type name */ - jintArray techList; - jintArray handleList; - jintArray typeList; - nfc_jni_get_technology_tree(e, psRemoteDevList,uNofRemoteDev, &techList, - &handleList, &typeList); - - // TODO: Should use the "connected" technology, for now use the first - if ((techList != NULL) && e->GetArrayLength(techList) > 0) { - jint* technologies = e->GetIntArrayElements(techList, 0); - SecureElementTech = technologies[0]; - TRACE("Store Secure Element Info\n"); - SecureElementInfo = psRemoteDevList->psRemoteDevInfo; - - TRACE("Discovered secure element: tech=%d", SecureElementTech); - } - else { - LOGE("Discovered secure element, but could not resolve tech"); - status = NFCSTATUS_FAILED; - } + secureElementHandle = psRemoteDevList->hTargetDev; } + + TRACE("Secure Element Handle: 0x%08x", secureElementHandle); + + /* Set type name */ + jintArray techList; + jintArray handleList; + jintArray typeList; + nfc_jni_get_technology_tree(e, psRemoteDevList,uNofRemoteDev, &techList, + &handleList, &typeList); + + // TODO: Should use the "connected" technology, for now use the first + if ((techList != NULL) && e->GetArrayLength(techList) > 0) { + jint* technologies = e->GetIntArrayElements(techList, 0); + SecureElementTech = technologies[0]; + e->ReleaseIntArrayElements(techList, technologies, JNI_ABORT); + TRACE("Store Secure Element Info\n"); + SecureElementInfo = psRemoteDevList->psRemoteDevInfo; + + TRACE("Discovered secure element: tech=%d", SecureElementTech); + } + else { + LOGE("Discovered secure element, but could not resolve tech"); + status = NFCSTATUS_FAILED; + } } pContextData->status = status; |