|
|
ac385c |
From f3304710b72de55249ef461c544edffd5705bdc7 Mon Sep 17 00:00:00 2001
|
|
|
ac385c |
From: Peter Jones <pjones@redhat.com>
|
|
|
ac385c |
Date: Mon, 1 May 2017 14:42:25 -0400
|
|
|
ac385c |
Subject: [PATCH 05/22] make_mac_path(): fix leaked file descriptor.
|
|
|
ac385c |
|
|
|
ac385c |
When make_mac_path() gets an error from efidp_make_mac_addr(), it fails
|
|
|
ac385c |
to close the file descriptor to the network device. So close it. Also
|
|
|
ac385c |
ensure that the ifrn_name field is NUL terminated.
|
|
|
ac385c |
|
|
|
ac385c |
Found by covscan.
|
|
|
ac385c |
|
|
|
ac385c |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
ac385c |
---
|
|
|
ac385c |
src/linux.c | 4 +++-
|
|
|
ac385c |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
ac385c |
|
|
|
ac385c |
diff --git a/src/linux.c b/src/linux.c
|
|
|
ac385c |
index 34ed479..3c77a93 100644
|
|
|
ac385c |
--- a/src/linux.c
|
|
|
ac385c |
+++ b/src/linux.c
|
|
|
ac385c |
@@ -1035,6 +1035,7 @@ make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname)
|
|
|
ac385c |
|
|
|
ac385c |
memset(&ifr, 0, sizeof (ifr));
|
|
|
ac385c |
strncpy(ifr.ifr_name, ifname, IF_NAMESIZE);
|
|
|
ac385c |
+ ifr.ifr_name[IF_NAMESIZE-1] = '\0';
|
|
|
ac385c |
drvinfo.cmd = ETHTOOL_GDRVINFO;
|
|
|
ac385c |
ifr.ifr_data = (caddr_t)&drvinfo;
|
|
|
ac385c |
|
|
|
ac385c |
@@ -1062,7 +1063,8 @@ make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname)
|
|
|
ac385c |
(uint8_t *)ifr.ifr_ifru.ifru_hwaddr.sa_data,
|
|
|
ac385c |
sizeof(ifr.ifr_ifru.ifru_hwaddr.sa_data));
|
|
|
ac385c |
if (sz < 0)
|
|
|
ac385c |
- return -1;
|
|
|
ac385c |
+ goto err;
|
|
|
ac385c |
+
|
|
|
ac385c |
off += sz;
|
|
|
ac385c |
ret = off;
|
|
|
ac385c |
err:
|
|
|
ac385c |
--
|
|
|
ac385c |
2.12.2
|
|
|
ac385c |
|