diff options
Diffstat (limited to 'ax25ipd/bpqether.c')
-rw-r--r-- | ax25ipd/bpqether.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ax25ipd/bpqether.c b/ax25ipd/bpqether.c index db02839..9c0e8e2 100644 --- a/ax25ipd/bpqether.c +++ b/ax25ipd/bpqether.c @@ -139,8 +139,19 @@ static int tun_alloc(char *dev) */ ifr.ifr_flags = IFF_TAP; if (*dev) { - strncpy(ifr.ifr_name, dev, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ-1] = 0; + /* + * This error check convinces GCC the following strncpy + * won't overflow its destination. + * Sadly the rest of the code is such spaghetty that I + * can't convince myself this is not possible either. + */ + if (strlen(dev) >= IFNAMSIZ) { + close(fd); + fprintf(stderr, "Network device name \"%s\" exceeds system limit %d / IFNAMSIZ.\n", dev, IFNAMSIZ); + + return -1; + } + strcpy(ifr.ifr_name, dev); } err = ioctl(fd, TUNSETIFF, (void *)&ifr); |