mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 14:38:09 +02:00
cloud-setup: strip whitespace from nmcs_utils_hwaddr_normalize()
This function should be accepting, and not reject leading/trailing white space.
This commit is contained in:
parent
494819bbbf
commit
2ba984a80a
1 changed files with 15 additions and 7 deletions
|
|
@ -485,22 +485,30 @@ char *
|
|||
nmcs_utils_hwaddr_normalize(const char *hwaddr, gssize len)
|
||||
{
|
||||
gs_free char *hwaddr_clone = NULL;
|
||||
char * hw;
|
||||
guint8 buf[ETH_ALEN];
|
||||
gsize l;
|
||||
|
||||
nm_assert(len >= -1);
|
||||
|
||||
if (len < 0) {
|
||||
if (!hwaddr)
|
||||
return NULL;
|
||||
} else {
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
nm_assert(hwaddr);
|
||||
hwaddr = nm_strndup_a(300, hwaddr, len, &hwaddr_clone);
|
||||
}
|
||||
l = strlen(hwaddr);
|
||||
} else
|
||||
l = len;
|
||||
|
||||
if (l == 0)
|
||||
return NULL;
|
||||
|
||||
nm_assert(hwaddr);
|
||||
hw = nm_strndup_a(300, hwaddr, l, &hwaddr_clone);
|
||||
|
||||
g_strstrip(hw);
|
||||
|
||||
/* we cannot use _nm_utils_hwaddr_aton() because that requires a delimiter.
|
||||
* Azure exposes MAC addresses without delimiter, so accept that too. */
|
||||
if (!nm_utils_hexstr2bin_full(hwaddr,
|
||||
if (!nm_utils_hexstr2bin_full(hw,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue