@@ -130,12 +130,12 @@ pub enum MbiLoadError {
130
130
/// according to the spec.
131
131
#[ display( fmt = "The address is invalid" ) ]
132
132
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.
136
135
#[ display( fmt = "The size of the MBI is unexpected" ) ]
137
136
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.
139
139
#[ display( fmt = "There is no end tag" ) ]
140
140
NoEndTag ,
141
141
}
@@ -148,7 +148,7 @@ impl core::error::Error for MbiLoadError {}
148
148
#[ repr( C ) ]
149
149
pub struct BootInformationHeader {
150
150
// size is multiple of 8
151
- total_size : u32 ,
151
+ pub total_size : u32 ,
152
152
_reserved : u32 ,
153
153
// Followed by the boot information tags.
154
154
}
@@ -235,9 +235,8 @@ impl<'a> BootInformation<'a> {
235
235
// mbi: reference to basic header
236
236
let mbi = & * ptr;
237
237
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 {
241
240
return Err ( MbiLoadError :: IllegalTotalSize ( mbi. total_size ) ) ;
242
241
}
243
242
0 commit comments