summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2017-01-24 18:32:01 -0800
committerAndre Eisenbach <eisenbach@google.com>2017-01-25 18:21:28 +0000
commit2ed0b48abb1fbc81dd16ec8ef0f6de8da590e86b (patch)
tree422d636d140001cdfc495b8d5041115c8f8e430c /core/java
parent35c715332f9c5ea6bd91f4b26c954ef89026e814 (diff)
nfc: Make NDEF validation stricter
- Check if the MB is not set for any record apart from the first one. - If the record is chunked, first record must contain the type Bug: 20722275 Test: Manual; write raw NDEF messages to a tag Change-Id: I3e73fc5163bbcd8a1f23417e98f57b665f4f1fad Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/nfc/NdefRecord.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index 83d17ba7fdd2..bd3231464ccf 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -805,7 +805,7 @@ public final class NdefRecord implements Parcelable {
if (!mb && records.size() == 0 && !inChunk && !ignoreMbMe) {
throw new FormatException("expected MB flag");
- } else if (mb && records.size() != 0 && !ignoreMbMe) {
+ } else if (mb && (records.size() != 0 || inChunk) && !ignoreMbMe) {
throw new FormatException("unexpected MB flag");
} else if (inChunk && il) {
throw new FormatException("unexpected IL flag in non-leading chunk");
@@ -839,6 +839,9 @@ public final class NdefRecord implements Parcelable {
if (cf && !inChunk) {
// first chunk
+ if (typeLength == 0) {
+ throw new FormatException("expected non-zero type length in first chunk");
+ }
chunks.clear();
chunkTnf = tnf;
}