ofp-util: Avoid use-after-free in ofputil_encode_flow_mod().
authorBen Pfaff <blp@nicira.com>
Sun, 24 Jun 2012 05:34:39 +0000 (22:34 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 25 Jun 2012 23:50:50 +0000 (16:50 -0700)
nx_put_match() can reallocate the ofpbuf's data so we need to reload the
pointer.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-util.c

index 6d820b2f40e3654986c716d2e27721b6ab21a5c5..cc3c9fdf98ae1a93ce700ee652b38f3460449fef 100644 (file)
@@ -1776,6 +1776,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
         nfm->cookie = fm->new_cookie;
         match_len = nx_put_match(msg, false, &fm->cr,
                                  fm->cookie, fm->cookie_mask);
+        nfm = msg->data;
         nfm->idle_timeout = htons(fm->idle_timeout);
         nfm->hard_timeout = htons(fm->hard_timeout);
         nfm->priority = htons(fm->cr.priority);