From: Hans Dedecker Date: Thu, 12 Apr 2018 20:36:38 +0000 (+0200) Subject: system-linux: remove unnecessary open call in system_if_dump_info() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=86a0e7c5e6934206e2f5624e2f8d3c3c25bf25b4;p=oweals%2Fnetifd.git system-linux: remove unnecessary open call in system_if_dump_info() Detected by coverity in CID 1329735 --- diff --git a/system-linux.c b/system-linux.c index 6fb0a01..3cdf3e4 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1708,16 +1708,12 @@ system_if_dump_info(struct device *dev, struct blob_buf *b) { struct ethtool_cmd ecmd; struct ifreq ifr; - char buf[64], *s; + char *s; void *c; - int dir_fd; - - snprintf(buf, sizeof(buf), "/sys/class/net/%s", dev->ifname); - dir_fd = open(buf, O_DIRECTORY); memset(&ecmd, 0, sizeof(ecmd)); memset(&ifr, 0, sizeof(ifr)); - strcpy(ifr.ifr_name, dev->ifname); + strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t) &ecmd; ecmd.cmd = ETHTOOL_GSET; @@ -1736,7 +1732,6 @@ system_if_dump_info(struct device *dev, struct blob_buf *b) blobmsg_add_string_buffer(b); } - close(dir_fd); return 0; }