diff --git a/uefi-test-runner/src/main.rs b/uefi-test-runner/src/main.rs index 98cd1e85..a1d07de3 100644 --- a/uefi-test-runner/src/main.rs +++ b/uefi-test-runner/src/main.rs @@ -10,6 +10,7 @@ extern crate alloc; use alloc::string::ToString; use alloc::vec::Vec; +use core::fmt::Write; use core::time::Duration; use uefi::mem::memory_map::MemoryMap; use uefi::prelude::*; @@ -116,7 +117,10 @@ fn send_request_helper(serial: &mut Serial, request: HostRequest) -> Result { serial.set_attributes(&io_mode)?; // Send a screenshot request to the host. - serial.write(request.as_bytes()).discard_errdata()?; + //serial.write(request.as_bytes()).discard_errdata()?; + serial + .write_str(request.as_str()) + .expect("should write all bytes"); // Wait for the host's acknowledgement before moving forward. let mut reply = [0; 3]; diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 158c23c1..5dc6d527 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -30,6 +30,7 @@ return `n` in any case. In the happy path, this always corresponds to the length if the provided data/buffer, but helps to cope with non-spec-compliant implementations. +- Fixed potential partial writes in `core::fmt::Write` impl of `Serial` protocol # uefi - v0.36.1 (2025-11-05) diff --git a/uefi/src/proto/console/serial.rs b/uefi/src/proto/console/serial.rs index 2dc9e11c..ecdadbbb 100644 --- a/uefi/src/proto/console/serial.rs +++ b/uefi/src/proto/console/serial.rs @@ -345,6 +345,6 @@ impl Serial { impl Write for Serial { fn write_str(&mut self, s: &str) -> fmt::Result { - self.write(s.as_bytes()).map(|_| ()).map_err(|_| fmt::Error) + self.write_exact(s.as_bytes()).map_err(|_| fmt::Error) } }