Skip to content

Commit a9e48c2

Browse files
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.
1 parent 30d33ec commit a9e48c2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

uefi/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939
> use uefi::table::boot::BootServices;
4040
```
4141

42+
43+
# uefi - 0.30.0 (unreleased)
44+
## Changed
45+
- **Breaking:**: Fixed a bug in the impls of `TryFrom<&[u8]>` for
46+
`&DevicePathHeader`, `&DevicePathNode` and `&DevicePath` that could lead to
47+
memory unsafety. See <https://github.com/rust-osdev/uefi-rs/issues/1281>.
48+
49+
4250
# uefi - 0.29.0 (2024-07-02)
4351

4452
## Added

uefi/src/proto/device_path/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub struct DevicePathHeader {
119119
pub length: u16,
120120
}
121121

122-
impl<'a> TryFrom<&[u8]> for &'a DevicePathHeader {
122+
impl<'a> TryFrom<&'a [u8]> for &'a DevicePathHeader {
123123
type Error = ByteConversionError;
124124

125125
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
@@ -265,7 +265,7 @@ impl PartialEq for DevicePathNode {
265265
}
266266
}
267267

268-
impl<'a> TryFrom<&[u8]> for &'a DevicePathNode {
268+
impl<'a> TryFrom<&'a [u8]> for &'a DevicePathNode {
269269
type Error = ByteConversionError;
270270

271271
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
@@ -516,7 +516,7 @@ impl PartialEq for DevicePath {
516516
}
517517
}
518518

519-
impl<'a> TryFrom<&[u8]> for &'a DevicePath {
519+
impl<'a> TryFrom<&'a [u8]> for &'a DevicePath {
520520
type Error = ByteConversionError;
521521

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

0 commit comments

Comments
 (0)