Remove `af_alg_iv::as_slice` and trait implementations that depend on it

These trait implementations exposed an unsound API (see
https://github.com/rust-lang/libc/issues/1501)
This commit is contained in:
Eduardo Sánchez Muñoz 2020-03-19 22:07:58 +01:00
parent 0d374002b8
commit 4b6ffb7aaf
2 changed files with 2 additions and 52 deletions

View File

@ -591,38 +591,13 @@ cfg_if! {
}
}
impl af_alg_iv {
fn as_slice(&self) -> &[u8] {
unsafe {
::core::slice::from_raw_parts(
self.iv.as_ptr(),
self.ivlen as usize
)
}
}
}
impl PartialEq for af_alg_iv {
fn eq(&self, other: &af_alg_iv) -> bool {
*self.as_slice() == *other.as_slice()
}
}
impl Eq for af_alg_iv {}
impl ::fmt::Debug for af_alg_iv {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("af_alg_iv")
.field("iv", &self.as_slice())
.field("ivlen", &self.ivlen)
.finish()
}
}
impl ::hash::Hash for af_alg_iv {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.as_slice().hash(state);
}
}
}
}

View File

@ -781,39 +781,14 @@ cfg_if! {
}
}
impl af_alg_iv {
fn as_slice(&self) -> &[u8] {
unsafe {
::core::slice::from_raw_parts(
self.iv.as_ptr(),
self.ivlen as usize
)
}
}
}
impl PartialEq for af_alg_iv {
fn eq(&self, other: &af_alg_iv) -> bool {
*self.as_slice() == *other.as_slice()
}
}
impl Eq for af_alg_iv {}
impl ::fmt::Debug for af_alg_iv {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("af_alg_iv")
.field("iv", &self.as_slice())
.field("ivlen", &self.ivlen)
.finish()
}
}
impl ::hash::Hash for af_alg_iv {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.as_slice().hash(state);
}
}
impl PartialEq for mq_attr {
fn eq(&self, other: &mq_attr) -> bool {
self.mq_flags == other.mq_flags &&