diff --git a/src/integrations/bootloader_interface.rs b/src/integrations/bootloader_interface.rs index 5cbca63..7b3110d 100644 --- a/src/integrations/bootloader_interface.rs +++ b/src/integrations/bootloader_interface.rs @@ -85,8 +85,10 @@ impl BootloaderInterface { .encode_utf16() .flat_map(|c| c.to_le_bytes()) .collect::>(); - // 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", diff --git a/src/utils/variables.rs b/src/utils/variables.rs index 8448be7..38ae9c7 100644 --- a/src/utils/variables.rs +++ b/src/utils/variables.rs @@ -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::>(); + // Add a null terminator to the end of the value. + encoded.push(0); self.set(key, &encoded, class) }