diff options
author | Thomas Haller <thaller@redhat.com> | 2021-03-12 09:42:38 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-03-12 12:40:26 +0100 |
commit | ebcd9b12fb21b38c25293688a6e01dc92219bc6a (patch) | |
tree | f2228386c4620dd474923dfbc6b1fe12d9b28e5d | |
parent | 839d7d5fbe1cbd3259568d7c98d7e92e425a0c64 (diff) | |
download | NetworkManager-ebcd9b12fb21b38c25293688a6e01dc92219bc6a.tar.gz |
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.
-rw-r--r-- | src/libnm-client-impl/nm-device.c | 7 |
1 files changed, 6 insertions, 1 deletions
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); |