From 6b6099a630510cab290a6115ebf4100e630cd497 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 8 Dec 2012 23:35:39 +0100 Subject: Maximum interface name length is IFNAMSIZ-1, not IFNAMSIZ Linux handles the string just fine without NULL termination, but that doesn't make it correct... --- src/fastd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastd.c b/src/fastd.c index 392b6c4..3b8531f 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -283,7 +283,7 @@ static void init_tuntap(fastd_context *ctx) { memset(&ifr, 0, sizeof(ifr)); if (ctx->conf->ifname) - strncpy(ifr.ifr_name, ctx->conf->ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, ctx->conf->ifname, IFNAMSIZ-1); switch (ctx->conf->mode) { case MODE_TAP: @@ -302,7 +302,7 @@ static void init_tuntap(fastd_context *ctx) { if (ioctl(ctx->tunfd, TUNSETIFF, &ifr) < 0) exit_errno(ctx, "TUNSETIFF ioctl failed"); - ctx->ifname = strndup(ifr.ifr_name, IFNAMSIZ); + ctx->ifname = strndup(ifr.ifr_name, IFNAMSIZ-1); int ctl_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (ctl_sock < 0) -- cgit v1.2.3