summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-04-30 04:51:43 +0200
committerArne Schwabe <arne@rfc2549.org>2012-04-30 04:51:43 +0200
commit73f914bdc1a681f827ed2375820c2d171e31bb0b (patch)
tree183ef914f933dd6c57640368eff0e20ab617f868
parent2f73ef1dda56ba7ae588091e0c0e8f71c02bbf32 (diff)
Version 0.4.4
Fix parsing of certain netmasks Fix custom Routes parsing
-rw-r--r--AndroidManifest.xml4
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java27
-rw-r--r--src/de/blinkt/openvpn/VpnProfile.java4
3 files changed, 25 insertions, 10 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d7f7e082..ab438faf 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -17,8 +17,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.blinkt.openvpn"
- android:versionCode="11"
- android:versionName="0.4.3" >
+ android:versionCode="12"
+ android:versionName="0.4.4" >
<uses-permission android:name="android.permission.INTERNET" />
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index 031f2a14..644b060f 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -65,16 +65,27 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
String[] ipt = mask.split("\\.");
long netmask=0;
- netmask += Integer.parseInt(ipt[0]);
- netmask += Integer.parseInt(ipt[1])<< 8;
- netmask += Integer.parseInt(ipt[2])<< 16;
- netmask += Integer.parseInt(ipt[3])<< 24;
-
- len =0;
- while((netmask & 0x1) == 1) {
- len++;
+ netmask += Long.parseLong(ipt[0])<< 24;
+ netmask += Integer.parseInt(ipt[1])<< 16;
+ netmask += Integer.parseInt(ipt[2])<< 8;
+ netmask += Integer.parseInt(ipt[3]);
+
+ // Add 33. bit to ensure the loop terminates
+ netmask += 1l << 32;
+
+ int lenZeros = 0;
+ while((netmask & 0x1) == 0) {
+ lenZeros++;
netmask = netmask >> 1;
}
+ // Check if rest of netmask is only 1s
+ if(netmask != (0x1ffffffffl >> lenZeros)) {
+ // Asume no CIDR, set /32
+ len=32;
+ } else {
+ len =32 -lenZeros;
+ }
+
}
@Override
public String toString() {
diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java
index 4028f3d0..a1b7a06f 100644
--- a/src/de/blinkt/openvpn/VpnProfile.java
+++ b/src/de/blinkt/openvpn/VpnProfile.java
@@ -300,6 +300,10 @@ public class VpnProfile implements Serializable{
private Collection<String> getCustomRoutes() {
Vector<String> cidrRoutes=new Vector<String>();
+ if(mCustomRoutes==null) {
+ // No routes set, return empty vector
+ return cidrRoutes;
+ }
for(String route:mCustomRoutes.split("[\n \t]")) {
if(!route.equals("")) {
String cidrroute = cidrToIPAndNetmask(route);