summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-18 07:51:27 +0200
committerThomas Haller <thaller@redhat.com>2018-04-18 07:51:29 +0200
commita99d51cb501d4a4022273aeb0622e1a8eaac2657 (patch)
tree74e68d31248a42820e7e72abcc852ed069ea578d
parent0fa57069ad98e9f2d98b93aba6a41cadd095b284 (diff)
downloadNetworkManager-a99d51cb501d4a4022273aeb0622e1a8eaac2657.tar.gz
auth-manager: fix potential issue iterating modified CList in _dbus_new_proxy_cb()
In the loop, we invoke callbacks. What the callbacks do, is out of control of NMAuthManager. For example, they could cancel or schedule new requests. Especially, cancelling invalidate the stored @safe pointer. Fix that, by always iterate from the start of the list. Fixes: d0563f0733ed293d67e9a0f6503e28c3f1c08f1b
-rw-r--r--src/nm-auth-manager.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nm-auth-manager.c b/src/nm-auth-manager.c
index 7a9fcbfa4f..411f92263b 100644
--- a/src/nm-auth-manager.c
+++ b/src/nm-auth-manager.c
@@ -500,7 +500,7 @@ _dbus_new_proxy_cb (GObject *source_object,
NMAuthManagerPrivate *priv;
gs_free GError *error = NULL;
GDBusProxy *proxy;
- NMAuthManagerCallId *call_id, *safe;
+ NMAuthManagerCallId *call_id;
proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
@@ -516,10 +516,12 @@ _dbus_new_proxy_cb (GObject *source_object,
if (!priv->proxy) {
_LOGE ("could not create polkit proxy: %s", error->message);
- c_list_for_each_entry_safe (call_id, safe, &priv->calls_lst_head, calls_lst) {
+again:
+ c_list_for_each_entry (call_id, &priv->calls_lst_head, calls_lst) {
if (call_id->dbus_parameters) {
_LOG2T (call_id, "completed: failed due to no D-Bus proxy after startup");
_call_id_invoke_callback (call_id, FALSE, FALSE, error);
+ goto again;
}
}
return;