Skip to content

Commit 3ca2dd1

Browse files
committed
uefi: Fix ConfigurationString parsing needs to reverse VALUE bytes
1 parent 999e48d commit 3ca2dd1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

uefi/src/proto/hii/config_str.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl ConfigurationString {
128128
/// # Returns
129129
///
130130
/// An iterator over bytes.
131-
pub fn parse_bytes_from_hex(hex: &str) -> impl Iterator<Item = u8> {
131+
pub fn parse_bytes_from_hex(hex: &str) -> impl DoubleEndedIterator<Item = u8> {
132132
hex.as_bytes().chunks(2).map(|chunk| {
133133
let chunk = str::from_utf8(chunk).unwrap_or_default();
134134
u8::from_str_radix(chunk, 16).unwrap_or_default()
@@ -237,8 +237,11 @@ impl FromStr for ConfigurationString {
237237
}
238238
_ => return Err(ParseError::BlockName),
239239
};
240+
// The uefi specification declares `VALUE` as being a "number" of arbitrary length.
241+
// And numbers have to be endianness-corrected. Thus, the bytes represented by a value's
242+
// hex string of arbitrary length have to be reversed to account for that weird encoding.
240243
let value = match splitter.next() {
241-
Some(("VALUE", Some(data))) => Self::parse_bytes_from_hex(data).collect(),
244+
Some(("VALUE", Some(data))) => Self::parse_bytes_from_hex(data).rev().collect(),
242245
_ => return Err(ParseError::BlockConfig),
243246
};
244247

0 commit comments

Comments
 (0)