HistoryEditJSON (OSV)

RUSTSEC-2023-0017

maligned::align_first causes incorrect deallocation

Reported
Issued
Package
maligned (crates.io)
Type
INFO Unsound
Categories
Keywords
#unsound #alloc #align
Aliases
References
Patched
no patched versions
Affected Functions
Version
maligned::align_first
  • *
maligned::align_first_boxed
  • *
maligned::align_first_boxed_cloned
  • *
maligned::align_first_boxed_default
  • *

Description

maligned::align_first manually allocates with an alignment larger than T, and then uses Vec::from_raw_parts on that allocation to get a Vec<T>.

GlobalAlloc::dealloc requires that the layout argument must be the same layout that was used to allocate that block of memory.

When deallocating, Box and Vec may not respect the specified alignment and can cause undefined behavior.

Advisory available under CC0-1.0 license.