platform/netlink: use appropriate integer types in nla_policy

This commit is contained in:
Thomas Haller 2021-08-10 17:32:47 +02:00
parent 57d626c182
commit 76bcd78710
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 5 additions and 5 deletions

View file

@ -597,7 +597,7 @@ static int
validate_nla(const struct nlattr *nla, int maxtype, const struct nla_policy *policy)
{
const struct nla_policy *pt;
uint16_t minlen;
uint8_t minlen;
uint16_t len;
int type = nla_type(nla);
@ -609,7 +609,7 @@ validate_nla(const struct nlattr *nla, int maxtype, const struct nla_policy *pol
if (pt->type > NLA_TYPE_MAX)
g_return_val_if_reached(-NME_BUG);
if (pt->minlen)
if (pt->minlen > 0)
minlen = pt->minlen;
else
minlen = nla_attr_minlen[pt->type];
@ -619,7 +619,7 @@ validate_nla(const struct nlattr *nla, int maxtype, const struct nla_policy *pol
if (len < minlen)
return -NME_UNSPEC;
if (pt->maxlen && len > pt->maxlen)
if (pt->maxlen > 0 && len > pt->maxlen)
return -NME_UNSPEC;
switch (pt->type) {

View file

@ -55,10 +55,10 @@ const char *nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len)
struct nla_policy {
/* Type of attribute or NLA_UNSPEC */
uint16_t type;
uint8_t type;
/* Minimal length of payload required */
uint16_t minlen;
uint8_t minlen;
/* Maximal length of payload allowed */
uint16_t maxlen;