|
|
edecca |
From 340b09010e2c329608af82c2fbd8cb73209eb58c Mon Sep 17 00:00:00 2001
|
|
|
edecca |
Message-Id: <340b09010e2c329608af82c2fbd8cb73209eb58c@dist-git>
|
|
|
edecca |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
edecca |
Date: Fri, 13 Jul 2018 15:44:42 +0200
|
|
|
edecca |
Subject: [PATCH] virnetdevtap: Don't crash on !ifname in
|
|
|
edecca |
virNetDevTapInterfaceStats
|
|
|
edecca |
MIME-Version: 1.0
|
|
|
edecca |
Content-Type: text/plain; charset=UTF-8
|
|
|
edecca |
Content-Transfer-Encoding: 8bit
|
|
|
edecca |
|
|
|
edecca |
https://bugzilla.redhat.com/show_bug.cgi?id=1595184
|
|
|
edecca |
|
|
|
edecca |
Some domain <interfaces/> do not have a name (because they are
|
|
|
edecca |
not TAP devices). Therefore, if
|
|
|
edecca |
virNetDevTapInterfaceStats(net->ifname, ...) is called an instant
|
|
|
edecca |
crash occurs. In Linux version of the function strlen() is called
|
|
|
edecca |
over the name and in BSD version STREQ() is called.
|
|
|
edecca |
|
|
|
edecca |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
edecca |
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
edecca |
(cherry picked from commit 318d54e5201295239869655c2c60fb44d9d9466e)
|
|
|
edecca |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
edecca |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
edecca |
---
|
|
|
edecca |
src/util/virnetdevtap.c | 12 ++++++++++++
|
|
|
edecca |
1 file changed, 12 insertions(+)
|
|
|
edecca |
|
|
|
edecca |
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
|
|
|
edecca |
index bd0710ad2e..3118ca18e8 100644
|
|
|
edecca |
--- a/src/util/virnetdevtap.c
|
|
|
edecca |
+++ b/src/util/virnetdevtap.c
|
|
|
edecca |
@@ -691,6 +691,12 @@ virNetDevTapInterfaceStats(const char *ifname,
|
|
|
edecca |
FILE *fp;
|
|
|
edecca |
char line[256], *colon;
|
|
|
edecca |
|
|
|
edecca |
+ if (!ifname) {
|
|
|
edecca |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
edecca |
+ _("Interface name not provided"));
|
|
|
edecca |
+ return -1;
|
|
|
edecca |
+ }
|
|
|
edecca |
+
|
|
|
edecca |
fp = fopen("/proc/net/dev", "r");
|
|
|
edecca |
if (!fp) {
|
|
|
edecca |
virReportSystemError(errno, "%s",
|
|
|
edecca |
@@ -768,6 +774,12 @@ virNetDevTapInterfaceStats(const char *ifname,
|
|
|
edecca |
struct if_data *ifd;
|
|
|
edecca |
int ret = -1;
|
|
|
edecca |
|
|
|
edecca |
+ if (!ifname) {
|
|
|
edecca |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
edecca |
+ _("Interface name not provided"));
|
|
|
edecca |
+ return -1;
|
|
|
edecca |
+ }
|
|
|
edecca |
+
|
|
|
edecca |
if (getifaddrs(&ifap) < 0) {
|
|
|
edecca |
virReportSystemError(errno, "%s",
|
|
|
edecca |
_("Could not get interface list"));
|
|
|
edecca |
--
|
|
|
edecca |
2.18.0
|
|
|
edecca |
|