2 ms·
Strncpy is not used correctly either. strncpy(ifr.ifr_name, dev, IFNAMSIZ); will not necessarily NULL terminate ifr.ifr_name for all values of dev variable.
by megous 11y ago
Strncpy is not used correctly either.
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
will not necessarily NULL terminate ifr.ifr_name for all values of dev variable. NULL terminated input is assumed later when ifr.ifr_name is used in strcpy.
- user2994cb 11y agoIn this case, it seems the ioctl call will do the null termination & in fact, the kernel itself uses strcpy for that field (presumably OK since the device structure has a null terminated name): https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/tun.c?id=refs/tags/v4.5-rc6 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux....