From 244939790db685441feabada7b2ecee3b81a3fd0 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 31 Jan 1997 11:59:05 +0000 Subject: [PATCH] avoid some division by zero in hackish ways --- sbin/fdisk/fdisk.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index b720591921b..47004eef7ae 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.11 1997/01/27 21:57:36 rahnds Exp $ */ +/* $OpenBSD: fdisk.c,v 1.12 1997/01/31 11:59:05 deraadt Exp $ */ /* $NetBSD: fdisk.c,v 1.11 1995/10/04 23:11:19 ghudson Exp $ */ /* @@ -28,7 +28,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fdisk.c,v 1.11 1997/01/27 21:57:36 rahnds Exp $"; +static char rcsid[] = "$OpenBSD: fdisk.c,v 1.12 1997/01/31 11:59:05 deraadt Exp $"; #endif /* not lint */ #include @@ -608,10 +608,16 @@ dos(sector, cylinderp, headp, sectorp) { int cylinder, head; - cylinder = sector / dos_cylindersectors; + if (dos_cylindersectors) + cylinder = sector / dos_cylindersectors; + else + cylinder = 0; sector -= cylinder * dos_cylindersectors; - head = sector / dos_sectors; + if (dos_sectors) + head = sector / dos_sectors; + else + head = 0; sector -= head * dos_sectors; *cylinderp = DOSCYL(cylinder); -- 2.20.1