summaryrefslogtreecommitdiff
path: root/lib/ofpbuf.c
diff options
context:
space:
mode:
authorJarno Rajahalme <jarno@ovn.org>2016-03-07 11:00:44 -0800
committerJarno Rajahalme <jarno@ovn.org>2016-03-07 11:00:44 -0800
commitaacaeb373079bf774770c0f7f183873a6ce9bbb4 (patch)
tree8c86cab50128116773d85b78d1923791a2607388 /lib/ofpbuf.c
parent742c06cc8861aec292e2fafd1d161c7b7929fd81 (diff)
downloadopenvswitch-aacaeb373079bf774770c0f7f183873a6ce9bbb4.tar.gz
ofpbuf: Fix setting of 'msg' in ofpbuf_clone_with_headroom()
Commit 38876d31 fixed setting 'msg' when resizing an ofpbuf, but failed to fix the same issue in ofpbuf_clone_with_headroom(). Without this fix the newly cloned ofpbuf's 'msg', if non-NULL, will point to the buffer of the original ofpbuf. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
Diffstat (limited to 'lib/ofpbuf.c')
-rw-r--r--lib/ofpbuf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index eab523e31..1a090ee9c 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -185,7 +185,11 @@ ofpbuf_clone_with_headroom(const struct ofpbuf *b, size_t headroom)
new_buffer->header = (char *) new_buffer->data + header_offset;
}
- new_buffer->msg = b->msg;
+ if (b->msg) {
+ ptrdiff_t msg_offset = (char *) b->msg - (char *) b->data;
+
+ new_buffer->msg = (char *) new_buffer->data + msg_offset;
+ }
return new_buffer;
}