1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00

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_DATA(ptr) (((uint8_t*)(ptr)) + sizeof(*(ptr)))
#define KERNAUX_MULTIBOOT2_TAG_ALIGN 8
#define KERNAUX_MULTIBOOT2_HTAG_NEXT(tag_base) \ #define KERNAUX_MULTIBOOT2_HTAG_NEXT(tag_base) \
((struct KernAux_Multiboot2_HTagBase*)KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base)) ((struct KernAux_Multiboot2_HTagBase*)KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base))
#define KERNAUX_MULTIBOOT2_ITAG_NEXT(tag_base) \ #define KERNAUX_MULTIBOOT2_ITAG_NEXT(tag_base) \

View file

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

View file

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