summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorPhilipp Matthias Schaefer <philipp.matthias.schaefer@posteo.de>2016-12-10 21:29:50 +0100
committerPhilipp Matthias Schaefer <philipp.matthias.schaefer@posteo.de>2016-12-10 21:45:43 +0100
commit3faaca1ad2847ffb15fd7f42f63e10b3d85602fc (patch)
tree9353e00be3c23d236280b45d565b9b135bd4dbb9 /src/sys
parent2cfeb5758e1c4957acf4a8108a4c0793ef18a937 (diff)
downloadnix-3faaca1ad2847ffb15fd7f42f63e10b3d85602fc.zip
Fix ControlMessage::encode_into when encoding multiple messages
copy_bytes updates dst so that it points after the bytes that were just copied into it. encode_into did not advance the buffer in the same way when encoding the data.
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/socket/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index e041e6b6..26f0739d 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -238,8 +238,13 @@ impl<'a> ControlMessage<'a> {
let padlen = cmsg_align(mem::size_of_val(&cmsg)) -
mem::size_of_val(&cmsg);
- let buf2 = &mut &mut buf[padlen..];
- copy_bytes(fds, buf2);
+
+ let mut tmpbuf = &mut [][..];
+ mem::swap(&mut tmpbuf, buf);
+ let (_padding, mut remainder) = tmpbuf.split_at_mut(padlen);
+ mem::swap(buf, &mut remainder);
+
+ copy_bytes(fds, buf);
},
ControlMessage::Unknown(UnknownCmsg(orig_cmsg, bytes)) => {
copy_bytes(orig_cmsg, buf);