From: Ben Pfaff Date: Thu, 19 Jul 2012 07:15:19 +0000 (-0700) Subject: nx-match: Succeed pulling 0-byte nx-match from NULL buffer. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=openvswitch;a=commitdiff_plain;h=a3a0c29e2b11d8fcae86043cd16520ecbaa03731 nx-match: Succeed pulling 0-byte nx-match from NULL buffer. I don't think this corner case can come up in a real OpenFlow message, because the presence of the OpenFlow header guarantees that the ofpbuf's data is nonnull, but it did in a simple test that is coming up in a few commits. Signed-off-by: Ben Pfaff --- diff --git a/lib/nx-match.c b/lib/nx-match.c index 3e3b4c69..8b2a8229 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -99,6 +99,14 @@ nx_pull_match__(struct ofpbuf *b, unsigned int match_len, bool strict, assert((cookie != NULL) == (cookie_mask != NULL)); + cls_rule_init_catchall(rule, priority); + if (cookie) { + *cookie = *cookie_mask = htonll(0); + } + if (!match_len) { + return 0; + } + p = ofpbuf_try_pull(b, ROUND_UP(match_len, 8)); if (!p) { VLOG_DBG_RL(&rl, "nx_match length %u, rounded up to a " @@ -107,10 +115,6 @@ nx_pull_match__(struct ofpbuf *b, unsigned int match_len, bool strict, return OFPERR_OFPBMC_BAD_LEN; } - cls_rule_init_catchall(rule, priority); - if (cookie) { - *cookie = *cookie_mask = htonll(0); - } for (; (header = nx_entry_ok(p, match_len)) != 0; p += 4 + NXM_LENGTH(header), match_len -= 4 + NXM_LENGTH(header)) {