From 237836932b2f3a66a08a7020332496c96916e662 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Wed, 23 Mar 2016 16:39:00 +0100 Subject: More fixes in LogFileHandler --- .../java/de/blinkt/openvpn/core/LogFileHandler.java | 17 +++++++++++++++-- .../main/java/de/blinkt/openvpn/fragments/Utils.java | 11 ----------- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'main/src') 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 77bb26dc..a30cde5b 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java +++ b/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java @@ -136,12 +136,12 @@ class LogFileHandler extends Handler { } else { VpnStatus.logError(String.format(Locale.getDefault(), "Could not read log item from file: %d/%d: %s", - read, len, Utils.bytesToHex(buf, read))); + read, len, bytesToHex(buf, Math.max(read,80)))); } p.recycle(); //Next item - read = logFile.read(buf, 0, 2); + read = logFile.read(buf, 0, 4); itemsRead++; if (itemsRead > 2*VpnStatus.MAXLOGENTRIES) { VpnStatus.logError("Too many logentries read from cache, aborting."); @@ -161,4 +161,17 @@ class LogFileHandler extends Handler { } } + final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); + public static String bytesToHex(byte[] bytes, int len) { + len = Math.min(bytes.length, len); + char[] hexChars = new char[len * 2]; + for ( int j = 0; j < len; j++ ) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = hexArray[v >>> 4]; + hexChars[j * 2 + 1] = hexArray[v & 0x0F]; + } + return new String(hexChars); + } + + } diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java index 382a97f6..243eae98 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java @@ -263,15 +263,4 @@ public class Utils { return prefix + VpnProfile.INLINE_TAG + newData; } - final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); - public static String bytesToHex(byte[] bytes, int len) { - len = Math.min(bytes.length, len); - char[] hexChars = new char[len * 2]; - for ( int j = 0; j < len; j++ ) { - int v = bytes[j] & 0xFF; - hexChars[j * 2] = hexArray[v >>> 4]; - hexChars[j * 2 + 1] = hexArray[v & 0x0F]; - } - return new String(hexChars); - } } -- cgit v1.2.3