Skip to content

Commit

Permalink
ofp-errors: Ensure parsed OFPT_ERROR messages are properly aligned.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Dumitru Ceara <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
dceara authored and igsilya committed May 17, 2022
1 parent 933aaf9 commit 08c3e5e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ofp-errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 08c3e5e

Please sign in to comment.