aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-11-21 14:12:22 +0100
committerStefan Sperling <ssperling@sysmocom.de>2018-11-21 14:14:10 +0100
commitaee905b79016fec402e1d3b8fc0e6ce2332cb647 (patch)
tree8c2e663eef050377cbce6b2615ae8aeba21a0f32
parentfb75adfeda2372bbd0ebd2e13602eca78f505efa (diff)
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
-rw-r--r--lib/tun.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/tun.c b/lib/tun.c
index fa4c37d..6ae006b 100644
--- a/lib/tun.c
+++ b/lib/tun.c
@@ -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);