Advisory

RUSTSEC-2022-0074

Also known as: GHSA-gfgm-chr3-x6px

Summary

Force cast a &Vec<T> to &[T]

Details

In function Table::as_ref, a reference of vector is force cast to slice. There are multiple problems here:

  1. To guarantee the size is correct, we have to first do Vec::shrink_to_fit. The function requires a mutable reference, so we have to force cast from immutable to mutable, which is UB.
  2. Even if (1) is sound, &Vec<T> and &[T] still might not have the same layout. Treating them equally may lead to UB.

Severity

Not rated by the source.

Dates

Published
2022-12-02 12:00 UTC
Modified
2023-11-08 04:19 UTC

Affected packages and fixes

prettytable-rs

crates.io · All systems

Affected

  • introduced 0.0.0-0, fixed 0.10.0 (semver)

Fixed versions

0.10.0

Fix

  • Fixed version 0.10.0
    cargo update -p prettytable-rs --precise 0.10.0

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: RustSec Advisory Database · CC0-1.0

Sources & licences