ofp-actions: Fix some ofpbuf usage problems in write-actions code.
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>
Thu, 17 Oct 2013 15:51:23 +0000 (08:51 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 17 Oct 2013 15:53:51 +0000 (08:53 -0700)
This code kept a pointer to data that might have been reallocated.

For longer term, "nested" variants of some ofpact functions
which using ofpbuf->l3 might be desirable.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-actions.c

index 06f9f6b..a5b1090 100644 (file)
@@ -1403,8 +1403,10 @@ ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
         struct ofpact_nest *on;
         const union ofp_action *actions;
         size_t n_actions;
-        size_t start = ofpacts->size;
+        size_t start;
 
+        ofpact_pad(ofpacts);
+        start = ofpacts->size;
         on = ofpact_put(ofpacts, OFPACT_WRITE_ACTIONS,
                         offsetof(struct ofpact_nest, actions));
         get_actions_from_instruction(insts[OVSINST_OFPIT11_WRITE_ACTIONS],
@@ -1414,6 +1416,7 @@ ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
         if (error) {
             goto exit;
         }
+        on = ofpbuf_at_assert(ofpacts, start, sizeof *on);
         on->ofpact.len = ofpacts->size - start;
     }
     if (insts[OVSINST_OFPIT11_WRITE_METADATA]) {