Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
uefi: Fix lifetimes in device_path TryFrom<&[u8]> impls
The missing lifetime means that the &[u8] buffer could be freed while the
&DevicePath still exists, which is UB.

(cherry picked from commit a9e48c2)
  • Loading branch information
nicholasbishop committed Aug 2, 2024
commit 8b7ec4f72c7ecdac452c51247691aab05a541c21
8 changes: 8 additions & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# uefi - [Unreleased]



# uefi - 0.30.0 (unreleased)
## Changed
- **Breaking:**: Fixed a bug in the impls of `TryFrom<&[u8]>` for
`&DevicePathHeader`, `&DevicePathNode` and `&DevicePath` that could lead to
memory unsafety. See <https://github.com/rust-osdev/uefi-rs/issues/1281>.


# uefi - 0.29.0 (2024-07-02)

## Added
Expand Down
6 changes: 3 additions & 3 deletions uefi/src/proto/device_path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub struct DevicePathHeader {
pub length: u16,
}

impl<'a> TryFrom<&[u8]> for &'a DevicePathHeader {
impl<'a> TryFrom<&'a [u8]> for &'a DevicePathHeader {
type Error = ByteConversionError;

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -265,7 +265,7 @@ impl PartialEq for DevicePathNode {
}
}

impl<'a> TryFrom<&[u8]> for &'a DevicePathNode {
impl<'a> TryFrom<&'a [u8]> for &'a DevicePathNode {
type Error = ByteConversionError;

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -516,7 +516,7 @@ impl PartialEq for DevicePath {
}
}

impl<'a> TryFrom<&[u8]> for &'a DevicePath {
impl<'a> TryFrom<&'a [u8]> for &'a DevicePath {
type Error = ByteConversionError;

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
Expand Down