From 4e8eddd100bbc8429806a70620c90b72cfd29cb1 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 3 Feb 2017 18:07:39 +0100 Subject: [PATCH] dns-manager: fix a NULL dereference in error handling nm_spawn_process() only sets error if the g_spawn_sync() itself fails, not when the program ran returns a non-zero code. [148 059915.1567] dns-mgr: update-dns: updating resolv.conf [148 059915.1568] dns-mgr: Removing DNS information from /usr/bin/resolvconf No resolv.conf for interface NetworkManager Thread 1 "NetworkManager" received signal SIGSEGV, Segmentation fault. 0x0000555555 7c325 in nm_dns_manager_end_updates 1532 _LOGW ("could not commit DNS changes: %s", error->message); (gdb) bt full #0 0x0000555555 7c325 in nm_dns_manager_end_updates error = 0x0 --- src/dns/nm-dns-manager.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index dfd2fce19e..0435cc17d4 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -619,8 +619,16 @@ dispatch_resolvconf (NMDnsManager *self, _LOGI ("Removing DNS information from %s", RESOLVCONF_PATH); cmd = g_strconcat (RESOLVCONF_PATH, " -d ", "NetworkManager", NULL); - if (nm_spawn_process (cmd, error) != 0) + if (nm_spawn_process (cmd, error) != 0) { + if (error && !*error) { + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "%s returned error code", + RESOLVCONF_PATH); + } return SR_ERROR; + } return SR_SUCCESS; }