summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f81cea3)
This fixes a segfault when no Device has been specified and tinc exits, and it
would try to free() a static string. Thanks to Borg for spottin.
#include "net.h"
#include "route.h"
#include "utils.h"
#include "net.h"
#include "route.h"
#include "utils.h"
#define DEFAULT_DEVICE "/dev/tun0"
#define DEFAULT_DEVICE "/dev/tun0"
} device_type_t;
int device_fd = -1;
} device_type_t;
int device_fd = -1;
-char *device;
-char *iface;
-char *device_info;
+char *device = NULL;
+char *iface = NULL;
+static char *device_info = NULL;
static int device_total_in = 0;
static int device_total_out = 0;
#if defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD)
static int device_total_in = 0;
static int device_total_out = 0;
#if defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD)
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
- device = DEFAULT_DEVICE;
+ device = xstrdup(DEFAULT_DEVICE);
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
- iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
+ iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device);
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
static HANDLE device_handle = INVALID_HANDLE_VALUE;
char *device = NULL;
char *iface = NULL;
static HANDLE device_handle = INVALID_HANDLE_VALUE;
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;
static int device_total_in = 0;
static int device_total_out = 0;
#include "net.h"
#include "route.h"
#include "utils.h"
#include "net.h"
#include "route.h"
#include "utils.h"
typedef enum device_type_t {
DEVICE_TYPE_ETHERTAP,
typedef enum device_type_t {
DEVICE_TYPE_ETHERTAP,
static device_type_t device_type;
char *device;
char *iface;
static device_type_t device_type;
char *device;
char *iface;
-char ifrname[IFNAMSIZ];
-char *device_info;
+static char ifrname[IFNAMSIZ];
+static char *device_info;
static int device_total_in = 0;
static int device_total_out = 0;
static int device_total_in = 0;
static int device_total_out = 0;
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
- device = DEFAULT_DEVICE;
+ device = xstrdup(DEFAULT_DEVICE);
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
#ifdef HAVE_LINUX_IF_TUN_H
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
#ifdef HAVE_LINUX_IF_TUN_H
+ iface = xstrdup(netname);
- iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
+ iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device);
#endif
device_fd = open(device, O_RDWR | O_NONBLOCK);
#endif
device_fd = open(device, O_RDWR | O_NONBLOCK);
static HANDLE device_handle = INVALID_HANDLE_VALUE;
char *device = NULL;
char *iface = NULL;
static HANDLE device_handle = INVALID_HANDLE_VALUE;
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;
static int device_total_in = 0;
static int device_total_out = 0;
-DWORD WINAPI tapreader(void *bla) {
+static DWORD WINAPI tapreader(void *bla) {
int sock, err, status;
struct addrinfo *ai;
struct addrinfo hint = {
int sock, err, status;
struct addrinfo *ai;
struct addrinfo hint = {
#include "logger.h"
#include "utils.h"
#include "route.h"
#include "logger.h"
#include "utils.h"
#include "route.h"
int device_fd = -1;
char *device;
char *iface;
int device_fd = -1;
char *device;
char *iface;
-char ifrname[IFNAMSIZ];
-char *device_info;
+static char ifrname[IFNAMSIZ];
+static char *device_info;
static int device_total_in = 0;
static int device_total_out = 0;
static int device_total_in = 0;
static int device_total_out = 0;
- if(!get_config_string
- (lookup_config(config_tree, "Interface"), &iface))
- iface = "eth0";
+ if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
+ iface = xstrdup("eth0");
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
+ device = xstrdup(iface);
device_info = _("raw socket");
device_info = _("raw socket");
#include "logger.h"
#include "net.h"
#include "utils.h"
#include "logger.h"
#include "net.h"
#include "utils.h"
#define DEFAULT_DEVICE "/dev/tun"
int device_fd = -1;
char *device = NULL;
char *iface = NULL;
#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;
static int device_total_in = 0;
static int device_total_out = 0;
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
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));
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
static int data_fd = -1;
static int write_fd = -1;
static int state = 0;
static int data_fd = -1;
static int write_fd = -1;
static int state = 0;
+static char *device_info;
extern char *identname;
extern bool running;
extern char *identname;
extern bool running;