summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2016-04-27 14:25:26 +0300
committerArne Schwabe <arne@rfc2549.org>2016-04-27 14:25:26 +0300
commitc3523db9e76133c57043f75f42716b7c34bb5c0f (patch)
tree98c23dfa1f3c789efa6d1f1360acb3bbb4e10a9f
parentd478576ffc48d7caa7fa0e987f257c46eba157b5 (diff)
Do no try to restore strings of invalid length.
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/LogItem.java2
1 files changed, 2 insertions, 0 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/LogItem.java b/main/src/main/java/de/blinkt/openvpn/core/LogItem.java
index 57bc3e1e..d767e073 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/LogItem.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/LogItem.java
@@ -151,6 +151,8 @@ public class LogItem implements Parcelable {
if (len == 0) {
mMessage = null;
} else {
+ if (len > bb.remaining())
+ throw new IndexOutOfBoundsException("String length " + len + " is bigger than remaining bytes " + bb.remaining());
byte[] utf8bytes = new byte[len];
bb.get(utf8bytes);
mMessage = new String(utf8bytes, "UTF-8");