summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-10-10 17:08:00 +0200
committerArne Schwabe <arne@rfc2549.org>2012-10-10 17:08:00 +0200
commitfec229793525b0614174b771bcb6fd72f8c047d8 (patch)
tree0016a198219bb9be88f7a6440114c58244b98ae7
parente81132a1eb250e6b657bc970cd4964203bacdaa5 (diff)
Fix bug that causes segfault on reconnect
-rw-r--r--openvpn/src/openvpn/tun.c5
-rw-r--r--src/de/blinkt/openvpn/OpenVPNThread.java15
2 files changed, 12 insertions, 8 deletions
diff --git a/openvpn/src/openvpn/tun.c b/openvpn/src/openvpn/tun.c
index c05d78f8..1b2e5822 100644
--- a/openvpn/src/openvpn/tun.c
+++ b/openvpn/src/openvpn/tun.c
@@ -1405,7 +1405,7 @@ close_tun_generic (struct tuntap *tt)
if (tt->fd >= 0)
close (tt->fd);
if (tt->actual_name)
- free (tt->actual_name);
+ free (tt->actual_name);
clear_tuntap (tt);
}
@@ -1439,7 +1439,8 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu
msg (M_ERR, "ERROR: Cannot open TUN");
}
/* Set the actual name to a dummy name to enable scripts */
- tt->actual_name = "vpnservice-tun";
+ tt->actual_name = (char *) malloc(32);
+ strncpy(tt->actual_name, "vpnservice-tun",32);
gc_free (&gc);
}
diff --git a/src/de/blinkt/openvpn/OpenVPNThread.java b/src/de/blinkt/openvpn/OpenVPNThread.java
index 0bde3205..b4ead269 100644
--- a/src/de/blinkt/openvpn/OpenVPNThread.java
+++ b/src/de/blinkt/openvpn/OpenVPNThread.java
@@ -37,13 +37,16 @@ public class OpenVPNThread implements Runnable {
} catch (Exception e) {
Log.e(TAG, "Got " + e.toString());
} finally {
+ int exitvalue = 0;
try {
-
- } catch (Exception e) {
- // ignore
+ exitvalue = mProcess.exitValue();
+ } catch ( IllegalThreadStateException ite) {
+ OpenVPN.logError("Illegal Thread state: " + ite.getLocalizedMessage());
}
-
- OpenVPN.updateStateString("NOPROCESS","No process running");
+ if( exitvalue != 0)
+ OpenVPN.logError("Process exited with exit value " + exitvalue);
+
+ OpenVPN.updateStateString("NOPROCESS","No process running.");
mService.processDied();
@@ -89,7 +92,7 @@ public class OpenVPNThread implements Runnable {
return;
OpenVPN.logMessage(0, "P:", logline);
}
-
+
} catch (IOException e) {
OpenVPN.logMessage(0, "", "Error reading from output of OpenVPN process"+ e.getLocalizedMessage());