From 29a654d63189c96bdd5a3b0186f6bda0c4dcb399 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 29 Apr 2016 11:03:57 +0300 Subject: Fix another crash reading broken logs. --- main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java | 4 +++- main/src/main/java/de/blinkt/openvpn/core/LogItem.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'main') diff --git a/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java b/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java index 7bb9d134..43a3f30e 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java +++ b/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.nio.BufferOverflowException; import java.nio.ByteBuffer; import java.util.Locale; @@ -63,7 +64,7 @@ class LogFileHandler extends Handler { flushToDisk(); } - } catch (IOException e) { + } catch (IOException| BufferOverflowException e) { e.printStackTrace(); VpnStatus.logError("Error during log cache: " + msg.what); VpnStatus.logException(e); @@ -88,6 +89,7 @@ class LogFileHandler extends Handler { // We do not really care if the log cache breaks between Android upgrades, // write binary format to disc + byte[] liBytes = li.getMarschaledBytes(); writeEscapedBytes(liBytes); 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 d767e073..ebe884a8 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/LogItem.java +++ b/main/src/main/java/de/blinkt/openvpn/core/LogItem.java @@ -18,6 +18,7 @@ import android.util.Log; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; +import java.nio.BufferOverflowException; import java.nio.ByteBuffer; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -89,7 +90,7 @@ public class LogItem implements Parcelable { } - public byte[] getMarschaledBytes() throws UnsupportedEncodingException { + public byte[] getMarschaledBytes() throws UnsupportedEncodingException, BufferOverflowException { ByteBuffer bb = ByteBuffer.allocate(16384); -- cgit v1.2.3