From ecaf63f715ecbbc3a44b725c7f621bee268270a1 Mon Sep 17 00:00:00 2001 From: Wes Peters Date: Tue, 21 Sep 2004 06:46:44 +0000 Subject: [PATCH] Trap invalid sector size 0 in disk probe, refusing to add such a device to the list. This prevents crashes on /0 errors in 'lsdev' et al. Reviewed-by: jhb@ MT5 after: RE approval --- sys/boot/i386/libi386/biosdisk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index aeac2e38904c..b97a2685c29d 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -209,6 +209,10 @@ bd_int13probe(struct bdinfo *bd) if (!(v86.efl & 0x1) && /* carry clear */ ((v86.edx & 0xff) > ((unsigned)bd->bd_unit & 0x7f))) { /* unit # OK */ + if ((v86.ecx & 0x3f) == 0) { /* absurd sector size */ + DEBUG("Invalid geometry for unit %d", bd->bd_unit); + return(0); /* skip device */ + } bd->bd_flags |= BD_MODEINT13; bd->bd_type = v86.ebx & 0xff;