From f1249dcd6f75802f7e55534fb5d244aa9df1aa62 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 8 Dec 2023 21:20:46 -0500 Subject: [PATCH] From bzt, initialize drive parameter head & sector values to avoid potential divisions by 0 --- kernel/initdisk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index ee0dc3d..c466bb8 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -723,8 +723,13 @@ StandardBios: /* old way to get parameters */ init_call_intr(0x13, ®s); - if (regs.flags & 0x01) + if (regs.flags & 0x01) + { + /* to avoid division by zero later, use some sane defaults */ + driveParam->chs.Head = 16; + driveParam->chs.Sector = 63; goto ErrorReturn; + } /* int13h call returns max value, store as count (#) i.e. +1 for 0 based heads & cylinders */ driveParam->chs.Head = (regs.d.x >> 8) + 1; /* DH = max head value = # of heads - 1 (0-255) */