summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-12-08 23:35:39 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-12-08 23:35:39 +0100
commit6b6099a630510cab290a6115ebf4100e630cd497 (patch)
tree092c4d0364c97b558546df3ed4633f6eeac26790 /src
parent268aefb54c2c1ae04070169a4db5371507b0d46b (diff)
downloadfastd-6b6099a630510cab290a6115ebf4100e630cd497.tar
fastd-6b6099a630510cab290a6115ebf4100e630cd497.zip
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...
Diffstat (limited to 'src')
-rw-r--r--src/fastd.c4
1 files 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)