aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake McGinty <me@jake.su>2018-03-23 18:02:12 -0700
committerJake McGinty <me@jake.su>2018-03-23 18:02:12 -0700
commit3d322112085e99b4c46746aa68caabdad084c9e6 (patch)
treea3757f207ba9104d1e65823a678f08cc6920fc0f
parenttools: modified rudimentary wg-quick.bash for macOS (diff)
downloadwireguard-rs-3d322112085e99b4c46746aa68caabdad084c9e6.tar.xz
wireguard-rs-3d322112085e99b4c46746aa68caabdad084c9e6.zip
Revert "peer: zero out sessions when they're dropped"
This reverts commit a5bad2984b404b91670bbb634c79102b476a0b5a. This seems to be the cause of a segfault.
-rw-r--r--Cargo.lock10
-rw-r--r--Cargo.toml1
-rw-r--r--src/lib.rs1
-rw-r--r--src/peer.rs20
4 files changed, 5 insertions, 27 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ed267cd..b41cf8a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -161,14 +161,6 @@ dependencies = [
]
[[package]]
-name = "clear_on_drop"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "colored"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1465,7 +1457,6 @@ dependencies = [
"bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"chacha20-poly1305-aead 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"daemonize 0.2.3 (git+https://github.com/mcginty/daemonize)",
@@ -1537,7 +1528,6 @@ dependencies = [
"checksum chacha20-poly1305-aead 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77d2058ba29594f69c75e8a9018e0485e3914ca5084e3613cd64529042f5423b"
"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9"
"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536"
-"checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17"
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
"checksum criterion 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e8852a0db5351470bbae05adaf2f8247eb50bf61abad84dcddad025157a916c"
diff --git a/Cargo.toml b/Cargo.toml
index 7e93a9b..ef69c75 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,7 +34,6 @@ blake2-rfc = "0.2"
byteorder = "^1.2"
bytes = "0.4"
chacha20-poly1305-aead = "^0.1"
-clear_on_drop = "^0.2"
derive_deref = "^1.0"
failure = "^0.1"
futures = "^0.1"
diff --git a/src/lib.rs b/src/lib.rs
index d5dd0cf..a693518 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -19,7 +19,6 @@ extern crate blake2_rfc;
extern crate byteorder;
extern crate bytes;
extern crate chacha20_poly1305_aead;
-extern crate clear_on_drop;
extern crate hex;
extern crate mio;
extern crate nix;
diff --git a/src/peer.rs b/src/peer.rs
index ce20d35..9e9a01e 100644
--- a/src/peer.rs
+++ b/src/peer.rs
@@ -1,6 +1,5 @@
use anti_replay::AntiReplay;
use byteorder::{ByteOrder, LittleEndian};
-use clear_on_drop::clear::{Clear, InitializableFromZeroed};
use consts::{TRANSPORT_OVERHEAD, TRANSPORT_HEADER_SIZE, REKEY_AFTER_MESSAGES, REKEY_AFTER_TIME,
REKEY_AFTER_TIME_RECV, REJECT_AFTER_TIME, REJECT_AFTER_MESSAGES, PADDING_MULTIPLE,
MAX_QUEUED_PACKETS};
@@ -101,15 +100,6 @@ impl Session {
})
}
}
-impl InitializableFromZeroed for Session {
- unsafe fn initialize(_place: *mut Self) {}
-}
-
-fn wipe_session(mut session: Session) -> u32 {
- let index = session.our_index;
- session.clear();
- index
-}
pub struct IncompleteIncomingHandshake {
their_index : u32,
@@ -138,7 +128,7 @@ impl Sessions {
mem::replace(&mut self.current, None),
mem::replace(&mut self.next, None)];
- indices.into_iter().filter_map(|sesh| sesh.map(wipe_session)).collect()
+ indices.into_iter().filter_map(|sesh| sesh.map(|s| s.our_index)).collect()
}
}
@@ -247,7 +237,7 @@ impl Peer {
let old_next = mem::replace(&mut self.sessions.next, Some(session));
let dead_index = if old_next.is_some() {
- mem::replace(&mut self.sessions.past, old_next).map(wipe_session)
+ mem::replace(&mut self.sessions.past, old_next).map(|session| session.our_index)
} else {
None
};
@@ -290,7 +280,7 @@ impl Peer {
let old_next = mem::replace(&mut self.sessions.next, Some(next_session.into_transport_mode()?));
let dead_index = if old_next.is_some() {
- mem::replace(&mut self.sessions.past, old_next).map(wipe_session)
+ mem::replace(&mut self.sessions.past, old_next).map(|session| session.our_index)
} else {
None
};
@@ -331,7 +321,7 @@ impl Peer {
let current = mem::replace(&mut self.sessions.current, Some(session));
let dead = mem::replace(&mut self.sessions.past, current);
- Ok(dead.map(wipe_session))
+ Ok(dead.map(|session| session.our_index))
}
pub fn handle_incoming_transport(&mut self, addr: SocketAddr, packet: &Transport)
@@ -373,7 +363,7 @@ impl Peer {
self.sessions.current.as_mut().unwrap().birthday = Timestamp::now();
self.last_handshake = Timestamp::now();
- SessionTransition::Transition(dead.map(wipe_session))
+ SessionTransition::Transition(dead.map(|session| session.our_index))
} else {
SessionTransition::NoTransition
};