Commit 87227315 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

more checking for malformed ndef records.

Change-Id: I0a788405b668ef76368fb746ca46d71da387beea
parent 13aac278
......@@ -111,6 +111,7 @@ public class TextRecord extends ParsedNdefRecord {
try {
byte[] payload = record.getPayload();
Preconditions.checkArgument(payload.length > 0);
/*
* payload[0] contains the "Status Byte Encodings" field, per
......
......@@ -223,6 +223,7 @@ public class UriRecord extends ParsedNdefRecord implements OnClickListener {
Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.RTD_URI));
byte[] payload = record.getPayload();
Preconditions.checkArgument(payload.length > 0);
/*
* payload[0] contains the URI Identifier Code, per the
......@@ -233,6 +234,8 @@ public class UriRecord extends ParsedNdefRecord implements OnClickListener {
*/
String prefix = URI_PREFIX_MAP.get(payload[0]);
Preconditions.checkArgument(prefix != null);
byte[] fullUri = Bytes.concat(
prefix.getBytes(Charset.forName("UTF-8")),
Arrays.copyOfRange(payload, 1, payload.length));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment