prettytable-rs: Force cast a &Vec<T> to &[T] may lead to undefined behavior
Moderate severity
GitHub Reviewed
Published
Dec 30, 2022
to the GitHub Advisory Database
•
Updated Jan 7, 2023
Description
Published to the GitHub Advisory Database
Dec 30, 2022
Reviewed
Dec 30, 2022
Last updated
Jan 7, 2023
In function
Table::as_ref
, a reference of vector is force cast to slice. There are multiple problems here:Vec::shrink_to_fit
. The function requires a mutable reference, so we have to force cast from immutable to mutable, which is undefined behavior (UB).&Vec<T>
and&[T]
still might not have the same layout. Treating them equally may lead to undefinted behavior (UB).References