File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 10
10
- ` SimpleNetwork::transmit ` now passes the correct buffer size argument.
11
11
Previously it incorrectly added the header size to the buffer length, which
12
12
could cause the firmware to read past the end of the buffer.
13
+ - The ` Display ` impl for ` CStr8 ` now excludes the trailing null character.
13
14
14
15
15
16
# uefi - 0.34.1 (2025-02-07)
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ impl fmt::Debug for CStr8 {
196
196
197
197
impl fmt:: Display for CStr8 {
198
198
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
199
- for c in self . 0 . iter ( ) {
199
+ for c in & self . 0 [ .. & self . 0 . len ( ) - 1 ] {
200
200
<Char8 as fmt:: Display >:: fmt ( c, f) ?;
201
201
}
202
202
Ok ( ( ) )
@@ -763,6 +763,7 @@ where
763
763
mod tests {
764
764
use super :: * ;
765
765
use crate :: { cstr16, cstr8} ;
766
+ use alloc:: format;
766
767
use alloc:: string:: String ;
767
768
768
769
// Tests if our CStr8 type can be constructed from a valid core::ffi::CStr
@@ -783,6 +784,18 @@ mod tests {
783
784
assert_eq ! ( <CStr8 as Borrow <[ u8 ] >>:: borrow( string) , & [ b'a' , 0 ] ) ;
784
785
}
785
786
787
+ #[ test]
788
+ fn test_cstr8_display ( ) {
789
+ let s = cstr8 ! ( "abc" ) ;
790
+ assert_eq ! ( format!( "{s}" ) , "abc" ) ;
791
+ }
792
+
793
+ #[ test]
794
+ fn test_cstr16_display ( ) {
795
+ let s = cstr16 ! ( "abc" ) ;
796
+ assert_eq ! ( format!( "{s}" ) , "abc" ) ;
797
+ }
798
+
786
799
#[ test]
787
800
fn test_cstr16_num_bytes ( ) {
788
801
let s = CStr16 :: from_u16_with_nul ( & [ 65 , 66 , 67 , 0 ] ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments