@@ -130,12 +130,12 @@ pub enum MbiLoadError {
130130 /// according to the spec.
131131 #[ display( fmt = "The address is invalid" ) ]
132132 IllegalAddress ,
133- /// The total size of the multiboot2 information structure must be a multiple of 8.
134- /// (Not in spec, but it is implicitly the case, because the begin of MBI
135- /// and all tags are 8-byte aligned and the end tag is exactly 8 byte long).
133+ /// The total size of the multiboot2 information structure must be not zero
134+ /// and a multiple of 8.
136135 #[ display( fmt = "The size of the MBI is unexpected" ) ]
137136 IllegalTotalSize ( u32 ) ,
138- /// End tag missing. Each multiboot2 header requires to have an end tag.
137+ /// Missing end tag. Each multiboot2 boot information requires to have an
138+ /// end tag.
139139 #[ display( fmt = "There is no end tag" ) ]
140140 NoEndTag ,
141141}
@@ -148,7 +148,7 @@ impl core::error::Error for MbiLoadError {}
148148#[ repr( C ) ]
149149pub struct BootInformationHeader {
150150 // size is multiple of 8
151- total_size : u32 ,
151+ pub total_size : u32 ,
152152 _reserved : u32 ,
153153 // Followed by the boot information tags.
154154}
@@ -235,9 +235,8 @@ impl<'a> BootInformation<'a> {
235235 // mbi: reference to basic header
236236 let mbi = & * ptr;
237237
238- // Check if total size is a multiple of 8.
239- // See MbiLoadError::IllegalTotalSize for comments
240- if mbi. total_size & 0b111 != 0 {
238+ // Check if total size is not 0 and a multiple of 8.
239+ if mbi. total_size == 0 || mbi. total_size & 0b111 != 0 {
241240 return Err ( MbiLoadError :: IllegalTotalSize ( mbi. total_size ) ) ;
242241 }
243242
0 commit comments