|
|
3e5111 |
From 6c74f5fdf8f882d89fd6a1c30fe017f2ed270a96 Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <6c74f5fdf8f882d89fd6a1c30fe017f2ed270a96@dist-git>
|
|
|
3e5111 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3e5111 |
Date: Fri, 21 Apr 2017 13:12:16 +0200
|
|
|
3e5111 |
Subject: [PATCH] util: check ifa_addr pointer before accessing its elements
|
|
|
3e5111 |
MIME-Version: 1.0
|
|
|
3e5111 |
Content-Type: text/plain; charset=UTF-8
|
|
|
3e5111 |
Content-Transfer-Encoding: 8bit
|
|
|
3e5111 |
|
|
|
3e5111 |
Reported by RafaĆ Wojciechowski <it@rafalwojciechowski.pl>.
|
|
|
3e5111 |
|
|
|
3e5111 |
Thread 1 (Thread 0x7f194b99d700 (LWP 5631)):
|
|
|
3e5111 |
0 virNetDevGetifaddrsAddress (addr=0x7f194b99c7c0, ifname=0x7f193400e2b0 "ovirtmgmt") at util/virnetdevip.c:738
|
|
|
3e5111 |
1 virNetDevIPAddrGet (ifname=0x7f193400e2b0 "ovirtmgmt", addr=addr@entry=0x7f194b99c7c0) at util/virnetdevip.c:795
|
|
|
3e5111 |
2 0x00007f19467800d6 in networkGetNetworkAddress (netname=<optimized out>, netaddr=netaddr@entry=0x7f1924013f18) at network/bridge_driver.c:4780
|
|
|
3e5111 |
3 0x00007f193e43a33c in qemuProcessGraphicsSetupNetworkAddress (listenAddr=0x7f19340f7650 "127.0.0.1", glisten=0x7f1924013f10) at qemu/qemu_process.c:4062
|
|
|
3e5111 |
4 qemuProcessGraphicsSetupListen (vm=<optimized out>, graphics=0x7f1924014f10, cfg=0x7f1934119f00) at qemu/qemu_process.c:4133
|
|
|
3e5111 |
5 qemuProcessSetupGraphics (flags=17, vm=0x7f19240155d0, driver=0x7f193411f1d0) at qemu/qemu_process.c:4196
|
|
|
3e5111 |
6 qemuProcessPrepareDomain (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=vm@entry=0x7f19240155d0, flags=flags@entry=17) at qemu/qemu_process.c:4969
|
|
|
3e5111 |
7 0x00007f193e4417c0 in qemuProcessStart (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=0x7f19240155d0,asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_START, migrateFrom=migrateFrom@entry=0x0, migrateFd=migrateFd@entry=-1, migratePath=migratePath@entry=0x0,snapshot=snapshot@entry=0x0, vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=17, flags@entry=1) at qemu/qemu_process.c:5553
|
|
|
3e5111 |
|
|
|
3e5111 |
Man page for getifaddrs also states that the "ifa_addr" may contain
|
|
|
3e5111 |
a null pointer which happens if there is an existing network interface
|
|
|
3e5111 |
on the host without IP address.
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3e5111 |
(cherry picked from commit 42000bf7e554b3732a569db633824302d5ec2867)
|
|
|
3e5111 |
|
|
|
3e5111 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1444408
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/util/virnetdevip.c | 7 ++++++-
|
|
|
3e5111 |
src/util/virnetdevtap.c | 3 +++
|
|
|
3e5111 |
2 files changed, 9 insertions(+), 1 deletion(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
|
|
|
3e5111 |
index c9ac6baf7..7a4fb1c91 100644
|
|
|
3e5111 |
--- a/src/util/virnetdevip.c
|
|
|
3e5111 |
+++ b/src/util/virnetdevip.c
|
|
|
3e5111 |
@@ -893,10 +893,15 @@ virNetDevGetifaddrsAddress(const char *ifname,
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
|
|
3e5111 |
- int family = ifa->ifa_addr->sa_family;
|
|
|
3e5111 |
+ int family;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (STRNEQ_NULLABLE(ifa->ifa_name, ifname))
|
|
|
3e5111 |
continue;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ if (!ifa->ifa_addr)
|
|
|
3e5111 |
+ continue;
|
|
|
3e5111 |
+ family = ifa->ifa_addr->sa_family;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
if (family != AF_INET6 && family != AF_INET)
|
|
|
3e5111 |
continue;
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
|
|
|
3e5111 |
index 02ef7fd24..93002b929 100644
|
|
|
3e5111 |
--- a/src/util/virnetdevtap.c
|
|
|
3e5111 |
+++ b/src/util/virnetdevtap.c
|
|
|
3e5111 |
@@ -762,6 +762,9 @@ virNetDevTapInterfaceStats(const char *ifname,
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
|
|
3e5111 |
+ if (!ifa->ifa_addr)
|
|
|
3e5111 |
+ continue;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
if (ifa->ifa_addr->sa_family != AF_LINK)
|
|
|
3e5111 |
continue;
|
|
|
3e5111 |
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.12.2
|
|
|
3e5111 |
|