Consistently allocate device and iface variables on the heap.
[oweals/tinc.git] / src / solaris / device.c
index 9c2a762a65ccb570f5eff47cb483249340119ef4..04a36a8580d9b64f2d7faf09841586cd9288dae3 100644 (file)
 #include "logger.h"
 #include "net.h"
 #include "utils.h"
+#include "xalloc.h"
 
 #define DEFAULT_DEVICE "/dev/tun"
 
 int device_fd = -1;
 char *device = NULL;
 char *iface = NULL;
-char *device_info = NULL;
+static char *device_info = NULL;
 
 static int device_total_in = 0;
 static int device_total_out = 0;
@@ -51,7 +52,7 @@ bool setup_device(void)
        cp();
 
        if(!get_config_string(lookup_config(config_tree, "Device"), &device))
-               device = DEFAULT_DEVICE;
+               device = xstrdup(DEFAULT_DEVICE);
 
        if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
                logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));