platform/netlink: assert for valid policy for string attribute in validate_nla

The policy for strings must indicate a minlen of at least 1.

Everything else is a bug, because the policy contains invalid
data -- and is determined at compile-time.
This commit is contained in:
Thomas Haller 2019-02-21 08:57:41 +01:00
parent 82e31b2816
commit f7df8fda1a

View file

@ -586,7 +586,11 @@ validate_nla (const struct nlattr *nla, int maxtype,
return -NME_UNSPEC;
if (pt->type == NLA_STRING) {
const char *data = nla_data (nla);
const char *data;
nm_assert (minlen > 0);
data = nla_data (nla);
if (data[nla_len (nla) - 1] != '\0')
return -NME_UNSPEC;
}