Skip to content

Commit

Permalink
datapath-windows/Netlink: Allow support for NESTED Attributes in NlAt…
Browse files Browse the repository at this point in the history
…trValidate

Signed-off-by: Ankur Sharma <[email protected]>
Acked-by: Alin Gabriel Serdean <[email protected]>
Acked-by: Eitan Eliahu <[email protected]>
Acked-by: Nithin Raju <[email protected]>
Acked-by: Samuel Ghinet <[email protected]>
Tested-by: Ankur Sharma <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
ankursh authored and blp committed Sep 29, 2014
1 parent dac9574 commit 91b95f8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions datapath-windows/ovsext/Netlink/Netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,12 +875,13 @@ NlAttrValidate(const PNL_ATTR nla, const PNL_POLICY policy)
UINT32 minLen;
UINT32 maxLen;
UINT32 len;
BOOLEAN ret = TRUE;
BOOLEAN ret = FALSE;

if ((policy->type == NL_A_NO_ATTR) ||
(policy->type == NL_A_VAR_LEN)) {
(policy->type == NL_A_VAR_LEN) ||
(policy->type == NL_A_NESTED)) {
/* Do not validate anything for attributes of type var length */
ret = FALSE;
ret = TRUE;
goto done;
}

Expand All @@ -899,25 +900,24 @@ NlAttrValidate(const PNL_ATTR nla, const PNL_POLICY policy)
if (len < minLen || len > maxLen) {
OVS_LOG_WARN("Attribute: %p, len: %d, not in valid range, "
"min: %d, max: %d", nla, len, minLen, maxLen);
ret = FALSE;
goto done;
}

/* Strings must be null terminated and must not have embedded nulls. */
if (policy->type == NL_A_STRING) {
if (((PCHAR) nla)[nla->nlaLen - 1]) {
OVS_LOG_WARN("Attributes %p lacks null at the end", nla);
ret = FALSE;
goto done;
}

if (memchr(nla + 1, '\0', len - 1) != NULL) {
OVS_LOG_WARN("Attributes %p has bad length", nla);
ret = FALSE;
goto done;
}
}

ret = TRUE;

done:
return ret;
}
Expand Down

0 comments on commit 91b95f8

Please sign in to comment.