From: deraadt Date: Fri, 31 Jan 1997 11:59:05 +0000 (+0000) Subject: avoid some division by zero in hackish ways X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=244939790db685441feabada7b2ecee3b81a3fd0;p=openbsd avoid some division by zero in hackish ways --- 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);