summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2013-12-31 11:32:16 -0800
committerBen Pfaff <blp@nicira.com>2013-12-31 11:40:16 -0800
commit8c64ab6870bede337e7469332275544519c5c606 (patch)
treecc11ec9ee8f3203e684a4ddf1f70729875562dc3
parent6e2c73dbc6392c65ccfa4797036020389acf7805 (diff)
downloadopenvswitch-8c64ab6870bede337e7469332275544519c5c606.tar.gz
odp-util: Avoid null dereference in parse_8021q_onward().
For parsing a mask, this code in parse_8021q_onward() always read out the OVS_KEY_ATTR_VLAN attribute without first checking whether it existed. The correct behavior, implemented by this commit, appears to be treating the VLAN as wildcarded and to continue parsing the flow. Bug #22312. Reported-by: Krishna Miriyala <miriyalak@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
-rw-r--r--lib/odp-util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 491b3723e..e2ac23e27 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -3047,7 +3047,9 @@ parse_8021q_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
if (!is_mask && !(present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_VLAN))) {
return ODP_FIT_TOO_LITTLE;
} else {
- tci = nl_attr_get_be16(attrs[OVS_KEY_ATTR_VLAN]);
+ tci = (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_VLAN)
+ ? nl_attr_get_be16(attrs[OVS_KEY_ATTR_VLAN])
+ : htons(0));
if (!is_mask) {
if (tci == htons(0)) {
/* Corner case for a truncated 802.1Q header. */