summaryrefslogtreecommitdiffstats
path: root/jni/com_android_nfc_NativeNfcSecureElement.cpp
diff options
context:
space:
mode:
authorJeff Hamilton <jham@android.com>2011-04-20 16:23:48 -0500
committerJeff Hamilton <jham@android.com>2011-04-20 16:23:48 -0500
commita8d8c1fa5058573c0d9d1305549c4326737db0b8 (patch)
tree3ab2acf565e2bdf3c56454977b390deafe17d7b2 /jni/com_android_nfc_NativeNfcSecureElement.cpp
parent7a7f8f8fd82936f0ee005ccfa7ac5c36760ed902 (diff)
downloadpackages_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-xjni/com_android_nfc_NativeNfcSecureElement.cpp76
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;