You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let base = unsafe{ base.add(base.align_offset(8))};
215
231
let base = base as*constHeaderTag;
216
-
Self{ base,n:0, size }
232
+
Self{
233
+
base,
234
+
n:0,
235
+
size,
236
+
tag_count:0,
237
+
end_tag_found:false,
238
+
}
217
239
}
218
240
}
219
241
220
242
implIteratorforMultiboot2HeaderTagIter{
221
243
typeItem = *constHeaderTag;
222
244
223
245
fnnext(&mutself) -> Option<Self::Item>{
224
-
ifself.n < self.size{
225
-
// transform to byte ptr => offset works correctly
226
-
let ptr = self.baseas*constu8;
227
-
let ptr = unsafe{ ptr.add(self.nasusize)};
228
-
let ptr = ptr as*constHeaderTag;
229
-
assert_eq!(ptr asusize % 8,0,"must be 8-byte aligned");
230
-
let tag = unsafe{&*ptr };
231
-
assert!(
232
-
tag.size() <= 500,
233
-
"no real mb2 header should be bigger than 500bytes - probably wrong memory?! is: {}",
234
-
{tag.size()}
235
-
);
236
-
self.n += tag.size();
237
-
// 8-byte alignment of pointer address
238
-
self.n += self.n % 8;
239
-
Some(ptr)
240
-
}else{
241
-
None
246
+
// no more bytes left to check; length reached
247
+
ifself.n >= self.size{
248
+
returnNone;
249
+
}
250
+
251
+
// transform to byte ptr => offset works correctly
252
+
let ptr = self.baseas*constu8;
253
+
let ptr = unsafe{ ptr.add(self.nasusize)};
254
+
let ptr = ptr as*constHeaderTag;
255
+
assert_eq!(ptr asusize % 8,0,"must be 8-byte aligned");
256
+
let tag = unsafe{&*ptr };
257
+
assert!(
258
+
tag.size() <= 500,
259
+
"no real mb2 header should be bigger than 500bytes - probably wrong memory?! is: {}",
260
+
{ tag.size()}
261
+
);
262
+
assert!(
263
+
tag.size() >= 8,
264
+
"no real mb2 header tag is smaller than 8 bytes - probably wrong memory?! is: {}",
265
+
{ tag.size()}
266
+
);
267
+
assert!(
268
+
!self.end_tag_found,
269
+
"There is more than one end tag! Maybe the `length` property is invalid?"
270
+
);
271
+
self.n += tag.size();
272
+
// 8-byte alignment of pointer address
273
+
self.n += self.n % 8;
274
+
self.tag_count += 1;
275
+
if tag.typ() == HeaderTagType::End{
276
+
self.end_tag_found = true;
242
277
}
278
+
assert!(self.tag_count < HeaderTagType::count(),"Invalid Multiboot2 header tags! There are more tags than technically possible! Maybe the `length` property is invalid?");
0 commit comments