aboutsummaryrefslogtreecommitdiffstats
path: root/src/platform/dummy/tun.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-23 14:14:08 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-23 14:14:08 +0200
commit3e829c04d1edfde1966a0d3f7f330fadd7ca9cd8 (patch)
tree5e749f39590eeedf56430c6cacf0a16af0fb2550 /src/platform/dummy/tun.rs
parentWork on pure WireGuard test (diff)
downloadwireguard-rs-3e829c04d1edfde1966a0d3f7f330fadd7ca9cd8.tar.xz
wireguard-rs-3e829c04d1edfde1966a0d3f7f330fadd7ca9cd8.zip
Fixed Ordering::Acquire -> Ordering::SeqCst typo
Diffstat (limited to '')
-rw-r--r--src/platform/dummy/tun.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/platform/dummy/tun.rs b/src/platform/dummy/tun.rs
index 9fe9480..fb87d2f 100644
--- a/src/platform/dummy/tun.rs
+++ b/src/platform/dummy/tun.rs
@@ -1,3 +1,4 @@
+use std::cmp::min;
use std::error::Error;
use std::fmt;
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -84,9 +85,10 @@ impl Reader for TunReader {
fn read(&self, buf: &mut [u8], offset: usize) -> Result<usize, Self::Error> {
match self.rx.recv() {
- Ok(m) => {
- buf[offset..].copy_from_slice(&m[..]);
- Ok(m.len())
+ Ok(msg) => {
+ let n = min(buf.len() - offset, msg.len());
+ buf[offset..offset + n].copy_from_slice(&msg[..n]);
+ Ok(n)
}
Err(_) => Err(TunError::Disconnected),
}