From 6135c0e7d56e3b0faf7e942ccbdc1a59f41d7ba6 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 1 Feb 2020 18:30:35 +0100 Subject: Fixed critical memory bug Overflow via >32 int --- src/kernel/interrupts/isr.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/interrupts/isr.c b/src/kernel/interrupts/isr.c index d89f581..42dbaa6 100644 --- a/src/kernel/interrupts/isr.c +++ b/src/kernel/interrupts/isr.c @@ -64,7 +64,7 @@ void isr_uninstall_handler(size_t isr) } // Error exception messages -const char *exception_messages[] = { +const char *exception_messages[32] = { "Division By Zero", "Debug", "Non Maskable Interrupt", @@ -117,14 +117,18 @@ void fault_handler(struct regs *r) r->eip, r->eax, r->ebx, r->ecx, r->edx, r->esp, faulting_address, r->eflags, r->err_code, r->int_no, exception_messages[r->int_no] ); - // halt_loop(); // Idk loop? - char *message = (char *) exception_messages[r->int_no]; - strcat(message, " Exception"); - - // Show message if there wasn't an error in video memory - if (faulting_address != (uint32_t) fb) - panic(message); - else - halt_loop(); + + if (r->int_no <= 32) { + char *message = (char *) exception_messages[r->int_no]; + strcat(message, " Exception"); + + // Show message if there wasn't an error in video memory + if (faulting_address != (uint32_t) fb) + panic(message); + else + halt_loop(); + } else { + panic("Unknown Exception"); + } } } \ No newline at end of file -- cgit v1.2.3