mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 10:30:17 +00:00
fix(variables): add null terminator to the end of strings written into variables
This commit is contained in:
@@ -85,8 +85,10 @@ impl BootloaderInterface {
|
||||
.encode_utf16()
|
||||
.flat_map(|c| c.to_le_bytes())
|
||||
.collect::<Vec<u8>>();
|
||||
// Write the bytes (including the null terminator) into the data buffer.
|
||||
// Write the bytes into the data buffer.
|
||||
data.extend_from_slice(&encoded);
|
||||
// Add a null terminator to the end of the entry.
|
||||
data.push(0);
|
||||
}
|
||||
Self::VENDOR.set(
|
||||
"LoaderEntries",
|
||||
|
||||
@@ -84,10 +84,12 @@ impl VariableController {
|
||||
/// a [CString16]. The variable `class` controls the attributes for the variable.
|
||||
pub fn set_cstr16(&self, key: &str, value: &str, class: VariableClass) -> Result<()> {
|
||||
// Encode the value as a CString16 little endian.
|
||||
let encoded = value
|
||||
let mut encoded = value
|
||||
.encode_utf16()
|
||||
.flat_map(|c| c.to_le_bytes())
|
||||
.collect::<Vec<u8>>();
|
||||
// Add a null terminator to the end of the value.
|
||||
encoded.push(0);
|
||||
self.set(key, &encoded, class)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user