From cba31136078207f2e8f778759ce4bdf5932a0f55 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 12 Mar 2021 09:42:38 +0100 Subject: [PATCH] libnm: guard against empty attribute names for NMLldpNeighbor The libnm API NMLldpNeighbor does not accept "" as an attribute name. And it does not need to, because a reasonable NetworkManager should never expose such names. However, we should not trust NetworkManager to be reasonable. Check that the attribute name is not empty. --- src/libnm-client-impl/nm-device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libnm-client-impl/nm-device.c b/src/libnm-client-impl/nm-device.c index 2522199d89..dd5f7d4889 100644 --- a/src/libnm-client-impl/nm-device.c +++ b/src/libnm-client-impl/nm-device.c @@ -247,8 +247,13 @@ _notify_update_prop_lldp_neighbors(NMClient * client, /* Note that there is no public API to mutate a NMLldpNeighbor instance. * This is the only place where we actually mutate it. */ neigh = nm_lldp_neighbor_new(); - while (g_variant_iter_next(attrs_iter, "{&sv}", &attr_name, &attr_variant)) + while (g_variant_iter_next(attrs_iter, "{&sv}", &attr_name, &attr_variant)) { + if (attr_name[0] == '\0') { + g_variant_unref(attr_variant); + continue; + } g_hash_table_insert(neigh->attrs, g_strdup(attr_name), attr_variant); + } g_ptr_array_add(new, neigh);