forked from Grouper-AOSP/platform_manifest
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpackages_apps_nfc.patch
112 lines (104 loc) · 4.29 KB
/
packages_apps_nfc.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
diff --git a/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c b/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c
index 6f58e08c..50e2deea 100755
--- a/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c
+++ b/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <log/log.h>
#include <nfc_api.h>
#include <rw_api.h>
#include <phNfcCompId.h>
@@ -1067,6 +1068,12 @@ NFCSTATUS Mfc_Transceive(uint8_t *p_data, uint32_t len)
NFCSTATUS status = NFCSTATUS_FAILED;
uint8_t i = 0x00;
+ if( len == 0 )
+ {
+ android_errorWriteLog(0x534e4554, "132082342");
+ return status;
+ }
+
gphNxpExtns_Context.RawWriteCallBack = FALSE;
gphNxpExtns_Context.CallBackMifare = NULL;
gphNxpExtns_Context.CallBackCtxt = NdefMap;
@@ -1074,6 +1081,11 @@ NFCSTATUS Mfc_Transceive(uint8_t *p_data, uint32_t len)
EXTNS_SetCallBackFlag(TRUE);
if( p_data[0] == 0x60 || p_data[0] == 0x61 )
{
+ if ( len < 12 )
+ {
+ android_errorWriteLog(0x534e4554, "125900276");
+ return status;
+ }
NdefMap->Cmd.MfCmd = p_data[0];
@@ -2051,6 +2063,12 @@ NFCSTATUS phFriNfc_ExtnsTransceive(phNfc_sTransceiveInfo_t *pTransceiveInfo,
uint32_t length = SendLength;
uint8_t restore_payload[]={0x00, 0x00, 0x00, 0x00,};
+ if( SendLength == 0 )
+ {
+ android_errorWriteLog(0x534e4554, "132083376");
+ return status;
+ }
+
buff = (uint8_t *)malloc((uint32_t)MAX_BUFF_SIZE);
if( NULL == buff )
{
diff --git a/src/com/android/nfc/BeamShareActivity.java b/src/com/android/nfc/BeamShareActivity.java
index 5b8acacd..f06bfdba 100644
--- a/src/com/android/nfc/BeamShareActivity.java
+++ b/src/com/android/nfc/BeamShareActivity.java
@@ -19,6 +19,8 @@ package com.android.nfc;
import java.util.ArrayList;
import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -26,6 +28,7 @@ import android.content.DialogInterface;
import android.content.ClipData;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.net.Uri;
import android.nfc.BeamShareData;
import android.nfc.NdefMessage;
@@ -33,8 +36,11 @@ import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.UserHandle;
+import android.os.RemoteException;
import android.util.Log;
+import android.util.EventLog;
import android.webkit.URLUtil;
+import android.Manifest.permission;
import com.android.internal.R;
@@ -211,16 +217,26 @@ public class BeamShareActivity extends Activity {
int numValidUris = 0;
for (Uri uri : mUris) {
try {
+ int uid = ActivityManagerNative.getDefault().getLaunchedFromUid(getActivityToken());
+ if (uri.getScheme().equalsIgnoreCase("file") &&
+ getApplicationContext().checkPermission(permission.READ_EXTERNAL_STORAGE, -1, uid) !=
+ PackageManager.PERMISSION_GRANTED) {
+ Log.e(TAG, "File based Uri doesn't have External Storage Permission.");
+ EventLog.writeEvent(0x534e4554, "37287958", uid, uri.getPath());
+ break;
+ }
grantUriPermission("com.android.nfc", uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
uriArray[numValidUris++] = uri;
if (DBG) Log.d(TAG, "Found uri: " + uri);
} catch (SecurityException e) {
Log.e(TAG, "Security exception granting uri permission to NFC process.");
- numValidUris = 0;
+ break;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Remote exception accessing uid of the calling process.");
break;
}
}
- if (numValidUris > 0) {
+ if (numValidUris != 0 && numValidUris == mUris.size()) {
shareData = new BeamShareData(null, uriArray, myUserHandle, 0);
} else {
// No uris left