From 2b4c0c63628ff9b432ec5d4b4c7b7ab2d4b02fb2 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 17 Apr 2017 13:02:39 +0200 Subject: [PATCH] Make sure realname is always initialized. --- src/bsd/device.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bsd/device.c b/src/bsd/device.c index 54282626..fbc75937 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -198,18 +198,19 @@ static bool setup_device(void) { // Guess what the corresponding interface is called - char *realname; + char *realname = NULL; #if defined(HAVE_FDEVNAME) - realname = fdevname(device_fd) ? : device; + realname = fdevname(device_fd); #elif defined(HAVE_DEVNAME) struct stat buf; if(!fstat(device_fd, &buf)) - realname = devname(buf.st_rdev, S_IFCHR) ? : device; -#else - realname = device; + realname = devname(buf.st_rdev, S_IFCHR); #endif + if(!realname) + realname = device; + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) iface = xstrdup(strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname); else if(strcmp(iface, strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname))