Better tun device name length handling.
[l2tpns.git] / l2tpns.c
index 8224275..9f5e901 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -611,8 +611,8 @@ static void inittun(void)
                LOG(0, 0, 0, "Can't set tun interface: %s\n", strerror(errno));
                exit(1);
        }
-       assert(strlen(ifr.ifr_name) < sizeof(config->tundevice));
-       strncpy(config->tundevice, ifr.ifr_name, sizeof(config->tundevice) - 1);
+       assert(strlen(ifr.ifr_name) < sizeof(config->tundevice) - 1);
+       strncpy(config->tundevice, ifr.ifr_name, sizeof(config->tundevice));
 
        {
                // get the interface index