Skip to content

Commit c54d7a2

Browse files
committed
protos/multiboot2: Bound information_request tag size to header area
1 parent fc55c10 commit c54d7a2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

common/protos/multiboot2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
164164
if (request->size < sizeof(struct multiboot_header_tag_information_request)) {
165165
panic(true, "multiboot2: Invalid information request tag size");
166166
}
167+
size_t tag_remaining = (uintptr_t)header + header->header_length - (uintptr_t)tag;
168+
if (request->size > tag_remaining) {
169+
panic(true, "multiboot2: Information request tag exceeds header bounds");
170+
}
167171
uint32_t size = (request->size - sizeof(struct multiboot_header_tag_information_request)) / sizeof(uint32_t);
168172

169173
for (uint32_t i = 0; i < size; i++) {

0 commit comments

Comments
 (0)