-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add advisory for uninitialized memory drop in byte_struct
- Loading branch information
1 parent
1794cae
commit d961492
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
```toml | ||
[advisory] | ||
id = "RUSTSEC-0000-0000" | ||
package = "byte_struct" | ||
date = "2021-03-01" | ||
url = "https://github.com/wwylele/byte-struct-rs/issues/1" | ||
categories = ["memory-corruption"] | ||
keywords = ["memory-safety"] | ||
|
||
[versions] | ||
patched = [">= 0.6.1"] | ||
``` | ||
|
||
# Deserializing an array can drop uninitialized memory on panic | ||
|
||
The `read_bytes_default_le` function for `[T; n]` arrays, used to deserialize | ||
arrays of `T` from bytes created a `[T; n]` array with `std::mem::uninitialized` | ||
and then called `T`'s deserialization method. | ||
|
||
If `T`'s deserialization method panicked, the uninitialized memory could drop | ||
invalid objects. | ||
|
||
This flaw was corrected in `a535678` by removing the unsafe block and using | ||
a `.map` function to deserialize each element of the array instead. |