libnm: allow nm_utils_hwaddr_valid() of length zero

nm_utils_hwaddr_valid() is used for validating strings. It should
not assert against calling it with an empty string "". That is just
an invalid hwaddr.
This commit is contained in:
Thomas Haller 2018-05-22 20:03:44 +02:00
parent c28b334fdd
commit 4e463df100

View file

@ -3827,9 +3827,11 @@ nm_utils_hwaddr_valid (const char *asc, gssize length)
if (!hwaddr_aton (asc, buf, length, &l))
return FALSE;
return length == l;
} else if (length == -1) {
} else if (length == -1)
return !!hwaddr_aton (asc, buf, sizeof (buf), &l);
} else
else if (length == 0)
return FALSE;
else
g_return_val_if_reached (FALSE);
}