wifi/iwd: in manager's interface_added() ensure known-network ID is not wrongly destroyed

Calling g_hash_table_insert() with a key which is already hashed
will destroy the *new* key. Since @id is used below, that would
be use after free.

Fixes: d635caf940551f8f5b52683b8379a1f81c58f8fc
This commit is contained in:
Thomas Haller 2018-09-05 12:17:03 +02:00
parent 2c8161868e
commit be875fe382

View file

@ -494,7 +494,7 @@ interface_added (GDBusObjectManager *object_manager, GDBusObject *object,
data = g_slice_new0 (KnownNetworkData);
data->known_network = (GDBusProxy *) g_object_ref (proxy);
g_hash_table_insert (priv->known_networks, id, data);
g_hash_table_replace (priv->known_networks, id, data);
if (security == NM_IWD_NETWORK_SECURITY_8021X)
mirror_8021x_connection (self, id, data);