check ioctl() call return value in tun_new()

Coverity complains about a missing ioctl() return value check.
Check for failure of the TUNSETNOCSUM ioctl and log a warning
if it fails.

Change-Id: I88da2164d975d7a232619b8d31c5eadeef0f3a80
Related: CID#57661
This commit is contained in:
Stefan Sperling 2018-11-21 14:12:22 +01:00
parent fb75adfeda
commit aee905b790
1 changed files with 4 additions and 1 deletions

View File

@ -193,7 +193,10 @@ int tun_new(struct tun_t **tun, const char *dev_name, bool use_kernel, int fd0,
strncpy((*tun)->devname, ifr.ifr_name, IFNAMSIZ);
(*tun)->devname[IFNAMSIZ - 1] = 0;
ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */
/* Disable checksums */
if (ioctl((*tun)->fd, TUNSETNOCSUM, 1) < 0) {
SYS_ERR(DTUN, LOGL_NOTICE, errno, "could not disable checksum on %s", (*tun)->devname);
}
return 0;
} else {
strncpy((*tun)->devname, dev_name, IFNAMSIZ);