From 9ad41ea28b2558053c4fb880462e16d5a5c5af61 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Fri, 19 Feb 2016 11:44:02 +0000
Subject: [PATCH] Check UTF-8 length of transport ID.

---
 briar-api/src/org/briarproject/api/TransportId.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/briar-api/src/org/briarproject/api/TransportId.java b/briar-api/src/org/briarproject/api/TransportId.java
index f7644891c0..0490df517c 100644
--- a/briar-api/src/org/briarproject/api/TransportId.java
+++ b/briar-api/src/org/briarproject/api/TransportId.java
@@ -1,17 +1,22 @@
 package org.briarproject.api;
 
+import java.nio.charset.Charset;
+
 /**
  * Type-safe wrapper for a string that uniquely identifies a transport plugin.
  */
 public class TransportId {
 
-	/** The maximum length of transport identifier in UTF-8 bytes. */
+	/**
+	 * The maximum length of transport identifier in UTF-8 bytes.
+	 */
 	public static int MAX_TRANSPORT_ID_LENGTH = 10;
 
 	private final String id;
 
 	public TransportId(String id) {
-		if (id.length() == 0 || id.length() > MAX_TRANSPORT_ID_LENGTH)
+		byte[] b = id.getBytes(Charset.forName("UTF-8"));
+		if (b.length == 0 || b.length > MAX_TRANSPORT_ID_LENGTH)
 			throw new IllegalArgumentException();
 		this.id = id;
 	}
-- 
GitLab