diff options
author | Thomas Haller <thaller@redhat.com> | 2016-06-08 00:56:13 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-06-30 08:29:54 +0200 |
commit | 76aa6f8e0defe8811f9bb28d4ec433b833b80d77 (patch) | |
tree | cab50d3bdc80148edb9899fcac6330e6c6e4d810 /libnm-core | |
parent | 83d231776b71b12103c2fbebfb29b052f796c87e (diff) | |
download | NetworkManager-76aa6f8e0defe8811f9bb28d4ec433b833b80d77.tar.gz |
libnm: don't serialize empty hardware address on D-Bus
_nm_utils_hwaddr_to_dbus() would serialize invalid hardware addresses
as "'cloned-mac-address': <@ay []>".
An empty array is treated the same as no hardware address set,
so we should not serialize it in the first place.
This is a change in behavior on how the connection is exported
on D-Bus, but it should not have any bad consequences.
We need this as we later want to deprecate the 'cloned-mac-address'
D-Bus field and overwrite it via a 'assigned-mac-address' field.
In this case, the "<@ay []>" is interfering. While it could be worked
around by treating an empty MAC address as "unset", fix it instead
and just not serialize it.
Diffstat (limited to 'libnm-core')
-rw-r--r-- | libnm-core/nm-utils.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 21cbe337a1..5c4bfb50b9 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -3316,17 +3316,20 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1, GVariant * _nm_utils_hwaddr_to_dbus (const GValue *prop_value) { - const char *str = g_value_get_string (prop_value); + const char *str; guint8 buf[NM_UTILS_HWADDR_LEN_MAX]; int len; - if (str) { - len = hwaddr_binary_len (str); - g_return_val_if_fail (len > 0 && len <= NM_UTILS_HWADDR_LEN_MAX, NULL); - if (!nm_utils_hwaddr_aton (str, buf, len)) - len = 0; - } else - len = 0; + str = g_value_get_string (prop_value); + if (!str) + return NULL; + + len = _nm_utils_hwaddr_length (str); + if (len == 0) + return NULL; + + if (!nm_utils_hwaddr_aton (str, buf, len)) + return NULL; return g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, buf, len, 1); } |