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.

  <debug> [148  059915.1567] dns-mgr: update-dns: updating resolv.conf
  <info>  [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
This commit is contained in:
Lubomir Rintel 2017-02-03 18:07:39 +01:00
parent 5216754b1e
commit 4e8eddd100

View file

@ -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;
}