safe transmute: require that src referent is smaller than dst
The source referent absolutely must be smaller than the destination referent of a ref-to-ref transmute; the excess bytes referenced cannot arise from thin air, even if those bytes are uninitialized.
This commit is contained in:
parent
a165f1f650
commit
216df4a8e6
8 changed files with 122 additions and 5 deletions
|
@ -266,6 +266,11 @@ where
|
|||
src_min_align: src_ref.min_align(),
|
||||
dst_min_align: dst_ref.min_align(),
|
||||
})
|
||||
} else if dst_ref.size() > src_ref.size() {
|
||||
Answer::No(Reason::DstRefIsTooBig {
|
||||
src: src_ref,
|
||||
dst: dst_ref,
|
||||
})
|
||||
} else {
|
||||
// ...such that `src` is transmutable into `dst`, if
|
||||
// `src_ref` is transmutability into `dst_ref`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue