Trim the ofpbuf to ensure proper alignment.

UB Sanitizer report:
  lib/ofp-print.c:1218:24: runtime error: member access within misaligned 
address 0x0000019229d2 for type 'const struct ofp_header', which requires 4 
byte alignment
  0x0000019229d2: note: pointer points here
   00 00  5a 5a 05 22 00 3e 00 00  00 09 00 00 00 00 00 00  00 03 05 0d 00 2e 
00 00  00 09 ff ff ff ff
                ^
      #0 0x7d45cc in ofp_to_string lib/ofp-print.c:1218
      #1 0x774fa8 in ofperr_msg_format lib/ofp-errors.c:253
      #2 0x7d2617 in ofp_print_error_msg lib/ofp-print.c:435
      #3 0x7d3eb7 in ofp_to_string__ lib/ofp-print.c:998
      #4 0x7d47fb in ofp_to_string lib/ofp-print.c:1244
      #5 0x8dcc4b in do_send lib/vconn.c:688
      #6 0x8dca64 in vconn_send lib/vconn.c:671

Acked-by: Aaron Conole <acon...@redhat.com>
Signed-off-by: Dumitru Ceara <dce...@redhat.com>
---
v6: Added Aaron's ack.
v5: Rebased.
v4: Rebased.
v3: Split out from old patch 07/11.
---
 lib/ofp-errors.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/ofp-errors.c b/lib/ofp-errors.c
index 35191abf16dd..eb099d355270 100644
--- a/lib/ofp-errors.c
+++ b/lib/ofp-errors.c
@@ -20,6 +20,7 @@
 #include "openflow/openflow.h"
 #include "openflow/nicira-ext.h"
 #include "openvswitch/dynamic-string.h"
+#include "openvswitch/ofp-actions.h"
 #include "openvswitch/ofp-errors.h"
 #include "openvswitch/ofp-msgs.h"
 #include "openvswitch/ofp-print.h"
@@ -346,6 +347,7 @@ ofperr_decode_msg(const struct ofp_header *oh, struct 
ofpbuf *payload)
     if (error && payload) {
         ofpbuf_init(payload, b.size);
         ofpbuf_push(payload, b.data, b.size);
+        ofpbuf_trim(payload);
     }
     return error;
 }

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to