Test total size alignment

This commit is contained in:
Alex Kotov 2022-01-13 19:43:57 +05:00
parent a6f8cbf6e7
commit e2c60d3819
3 changed files with 10 additions and 0 deletions

View File

@ -19,6 +19,8 @@ extern "C" {
#define KERNAUX_MULTIBOOT2_DATA(ptr) (((uint8_t*)(ptr)) + sizeof(*(ptr)))
#define KERNAUX_MULTIBOOT2_TAG_ALIGN 8
#define KERNAUX_MULTIBOOT2_HTAG_NEXT(tag_base) \
((struct KernAux_Multiboot2_HTagBase*)KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base))
#define KERNAUX_MULTIBOOT2_ITAG_NEXT(tag_base) \

View File

@ -26,6 +26,10 @@ bool KernAux_Multiboot2_Header_is_valid(
return false;
}
if (multiboot2_header->total_size % KERNAUX_MULTIBOOT2_TAG_ALIGN != 0) {
return false;
}
if (multiboot2_header->checksum !=
KERNAUX_MULTIBOOT2_CHECKSUM(
multiboot2_header->arch,

View File

@ -18,6 +18,10 @@ bool KernAux_Multiboot2_Info_is_valid(
return false;
}
if (multiboot2_info->total_size % KERNAUX_MULTIBOOT2_TAG_ALIGN != 0) {
return false;
}
const struct KernAux_Multiboot2_ITagBase *tag_base =
(struct KernAux_Multiboot2_ITagBase*)
KERNAUX_MULTIBOOT2_DATA(multiboot2_info);