summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Netlink
diff options
context:
space:
mode:
authorSairam Venugopal <vsairam@vmware.com>2015-08-26 14:37:16 -0700
committerBen Pfaff <blp@nicira.com>2015-08-26 16:37:39 -0700
commitb8b00f0ce4044fd6cb535f3514f5f6b205bf50a2 (patch)
tree62c785e73d1a65183e6d21de3905935dee1ab56d /datapath-windows/ovsext/Netlink
parent5e2e998a5ed76e7aab2cd5cdc277b59c160dd199 (diff)
downloadopenvswitch-b8b00f0ce4044fd6cb535f3514f5f6b205bf50a2.tar.gz
datapath-windows: Fix iterator in NlAttrParse()
Signed-off-by: Sairam Venugopal <vsairam@vmware.com> Acked-by: Nithin Raju <nithin@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath-windows/ovsext/Netlink')
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.c18
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.h6
2 files changed, 14 insertions, 10 deletions
diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index a62d76091..a66fb3833 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -1046,15 +1046,16 @@ NlAttrFindNested(const PNL_ATTR nla, UINT16 type)
BOOLEAN
NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen,
- const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs)
+ const NL_POLICY policy[], const UINT32 numPolicy,
+ PNL_ATTR attrs[], UINT32 numAttrs)
{
PNL_ATTR nla;
UINT32 left;
UINT32 iter;
BOOLEAN ret = FALSE;
+ UINT32 numPolicyAttr = MIN(numPolicy, numAttrs);
- RtlZeroMemory(attrs, n_attrs * sizeof *attrs);
+ RtlZeroMemory(attrs, numAttrs * sizeof *attrs);
/* There is nothing to parse */
@@ -1073,7 +1074,7 @@ NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
totalAttrLen)
{
UINT16 type = NlAttrType(nla);
- if (type < n_attrs && policy[type].type != NL_A_NO_ATTR) {
+ if (type < numPolicyAttr && policy[type].type != NL_A_NO_ATTR) {
/* Typecasting to keep the compiler happy */
const PNL_POLICY e = (const PNL_POLICY)(&policy[type]);
if (!NlAttrValidate(nla, e)) {
@@ -1094,7 +1095,7 @@ NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
goto done;
}
- for (iter = 0; iter < n_attrs; iter++) {
+ for (iter = 0; iter < numPolicyAttr; iter++) {
const PNL_POLICY e = (const PNL_POLICY)(&policy[iter]);
if (!e->optional && e->type != NL_A_NO_ATTR && !attrs[iter]) {
OVS_LOG_ERROR("Required attr:%d missing", iter);
@@ -1120,9 +1121,10 @@ done:
BOOLEAN
NlAttrParseNested(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen,
- const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs)
+ const NL_POLICY policy[], const UINT32 numPolicy,
+ PNL_ATTR attrs[], UINT32 numAttrs)
{
return NlAttrParse(nlMsg, attrOffset + NLA_HDRLEN,
- totalAttrLen - NLA_HDRLEN, policy, attrs, n_attrs);
+ totalAttrLen - NLA_HDRLEN, policy, numPolicy,
+ attrs, numAttrs);
}
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h
index 36ffee9bb..a520ccf57 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -133,10 +133,12 @@ const PNL_ATTR NlAttrFindNested(const PNL_ATTR nla,
UINT16 type);
BOOLEAN NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen, const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs);
+ const UINT32 numPolicy, PNL_ATTR attrs[],
+ UINT32 numAttrs);
BOOLEAN NlAttrParseNested(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen, const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs);
+ const UINT32 numPolicy, PNL_ATTR attrs[],
+ UINT32 numAttrs);
/*
* --------------------------------------------------------------------------
* Returns the length of attribute.