summaryrefslogtreecommitdiff
path: root/sbin/fdisk/fdisk.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-01-31 11:59:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-01-31 11:59:06 +0000
commit6c7279425c20943c2f006f41f92d41c668f4a20b (patch)
treebd880c10c5b726f199ef84310d669aa19ac74e15 /sbin/fdisk/fdisk.c
parent73c1328aece038c7e208458a3652b0687d036061 (diff)
avoid some division by zero in hackish ways
Diffstat (limited to 'sbin/fdisk/fdisk.c')
-rw-r--r--sbin/fdisk/fdisk.c14
1 files 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 <sys/param.h>
@@ -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);