mirror of
https://github.com/tailix/libkernaux.git
synced 2025-02-24 15:55:41 -05:00
Validate that Multiboot 2 memory map tag entru size is not 0
This commit is contained in:
parent
96d9f1e65e
commit
36dbe4b8a9
2 changed files with 19 additions and 0 deletions
|
@ -229,6 +229,7 @@ unsigned char KernAux_Multiboot2_Tag_MemoryMap_is_valid(
|
|||
return (
|
||||
tag->base.type == KERNAUX_MULTIBOOT2_TAGTYPE_MEMORY_MAP &&
|
||||
tag->base.size >= 16 &&
|
||||
tag->entry_size > 0 &&
|
||||
tag->entry_size % 8 == 0 &&
|
||||
(tag->base.size - 16) % tag->entry_size == 0
|
||||
);
|
||||
|
|
|
@ -421,6 +421,16 @@ static const struct {
|
|||
},
|
||||
};
|
||||
|
||||
static const struct KernAux_Multiboot2_Tag_MemoryMap
|
||||
tag_memory_map_with_empty_data_invalid_entry_size_zero = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_TAGTYPE_MEMORY_MAP,
|
||||
.size = 16,
|
||||
},
|
||||
.entry_size = 0,
|
||||
.entry_version = 0,
|
||||
};
|
||||
|
||||
static const struct KernAux_Multiboot2_Tag_MemoryMap
|
||||
tag_memory_map_with_empty_data_invalid_entry_size_not_mul8 = {
|
||||
.base = {
|
||||
|
@ -938,6 +948,10 @@ int main()
|
|||
&tag_memory_map_with_some_large_data_items_invalid_size.tag.base
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_TagBase_is_valid(
|
||||
&tag_memory_map_with_empty_data_invalid_entry_size_zero.base
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_TagBase_is_valid(
|
||||
&tag_memory_map_with_empty_data_invalid_entry_size_not_mul8.base
|
||||
));
|
||||
|
@ -1090,6 +1104,10 @@ int main()
|
|||
&tag_memory_map_with_some_large_data_items_invalid_size.tag
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_Tag_MemoryMap_is_valid(
|
||||
&tag_memory_map_with_empty_data_invalid_entry_size_zero
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_Tag_MemoryMap_is_valid(
|
||||
&tag_memory_map_with_empty_data_invalid_entry_size_not_mul8
|
||||
));
|
||||
|
|
Loading…
Add table
Reference in a new issue