aboutsummaryrefslogtreecommitdiff
path: root/lib/ofp-util.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-10-18 14:00:57 -0700
committerBen Pfaff <blp@nicira.com>2011-10-18 16:08:15 -0700
commit62698c77ecf6297b245a5c1857197f895f218ced (patch)
treee0447e4af617e0c25fd5487be75a7b66f5d3f0f2 /lib/ofp-util.c
parentc3636ffc10a2a016b89d05c9456b3fdc030d444c (diff)
ofp-util: Avoid misaligned memory access in ofputil_encode_packet_in().
Reported-by: Murphy McCauley <murphy.mccauley@gmail.com>
Diffstat (limited to 'lib/ofp-util.c')
-rw-r--r--lib/ofp-util.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index b46219a7..09301962 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1449,7 +1449,7 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
struct ofpbuf *rw_packet)
{
int total_len = pin->packet->size;
- struct ofp_packet_in *opi;
+ struct ofp_packet_in opi;
if (rw_packet) {
if (pin->send_len < rw_packet->size) {
@@ -1462,13 +1462,14 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
}
/* Add OFPT_PACKET_IN. */
- opi = ofpbuf_push_zeros(rw_packet, offsetof(struct ofp_packet_in, data));
- opi->header.version = OFP_VERSION;
- opi->header.type = OFPT_PACKET_IN;
- opi->total_len = htons(total_len);
- opi->in_port = htons(pin->in_port);
- opi->reason = pin->reason;
- opi->buffer_id = htonl(pin->buffer_id);
+ memset(&opi, 0, sizeof opi);
+ opi.header.version = OFP_VERSION;
+ opi.header.type = OFPT_PACKET_IN;
+ opi.total_len = htons(total_len);
+ opi.in_port = htons(pin->in_port);
+ opi.reason = pin->reason;
+ opi.buffer_id = htonl(pin->buffer_id);
+ ofpbuf_push(rw_packet, &opi, offsetof(struct ofp_packet_in, data));
update_openflow_length(rw_packet);
return rw_packet;