From 66715515dc0ff0d4f95c86d636009e5999fba0ed Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 24 Jun 2016 18:59:58 +0200 Subject: [PATCH] platform: avoid crash after calling nl_recv() for old libnl3 version nl_recv() in libnl3 before version 3.2.15 would return dangling pointers if nl_recv() fails or has nothing to read [1]. Workaround that by explicitly clearing @buf and @creds. https://bugzilla.gnome.org/show_bug.cgi?id=767986 [1] https://github.com/thom311/libnl/commit/69468517d0de1675d80f24661ff57a5dbac7275c --- src/platform/nm-linux-platform.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index f721277b36..2dcea911b4 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -5869,6 +5869,13 @@ continue_reading: errno = 0; n = nl_recv (sk, &nla, &buf, &creds); + if (n <= 0) { + /* workaround libnl3 <= 3.2.15 returning danling pointers in case nl_recv() + * fails. Fixed by libnl3 69468517d0de1675d80f24661ff57a5dbac7275c. */ + buf = NULL; + creds = NULL; + } + switch (n) { case 0: /* Work around a libnl bug fixed in 3.2.22 (375a6294) */