summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-10 12:14:20 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-10 12:14:20 +0000
commit55b78409b43975afa480b46368d0248e75557f28 (patch)
tree9e3b4c614b812294095a7630f413a7992a473a68
parentcb8686f338797fddb439f4892bc95531b530bd13 (diff)
avoid division by zero (avoid printing the incalculateable); netbsd pr#2683; nathanw@MIT.EDU
-rw-r--r--sbin/disklabel/disklabel.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 8ba45769fb1..41112c8ef5c 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.14 1996/06/25 01:21:57 deraadt Exp $ */
+/* $OpenBSD: disklabel.c,v 1.15 1996/08/10 12:14:19 deraadt Exp $ */
/* $NetBSD: disklabel.c,v 1.30 1996/03/14 19:49:24 ghudson Exp $ */
/*
@@ -48,7 +48,7 @@ static char copyright[] =
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
#else
-static char rcsid[] = "$OpenBSD: disklabel.c,v 1.14 1996/06/25 01:21:57 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: disklabel.c,v 1.15 1996/08/10 12:14:19 deraadt Exp $";
#endif
#endif /* not lint */
@@ -845,19 +845,22 @@ display(f, lp)
fprintf(f, "%20.20s", "");
break;
}
- fprintf(f, "\t# (Cyl. %4d",
- pp->p_offset / lp->d_secpercyl);
- if (pp->p_offset % lp->d_secpercyl)
- putc('*', f);
- else
- putc(' ', f);
- fprintf(f, "- %d",
- (pp->p_offset +
- pp->p_size + lp->d_secpercyl - 1) /
- lp->d_secpercyl - 1);
- if (pp->p_size % lp->d_secpercyl)
- putc('*', f);
- fprintf(f, ")\n");
+ if (lp->d_secpercyl) {
+ fprintf(f, "\t# (Cyl. %4d",
+ pp->p_offset / lp->d_secpercyl);
+ if (pp->p_offset % lp->d_secpercyl)
+ putc('*', f);
+ else
+ putc(' ', f);
+ fprintf(f, "- %d",
+ (pp->p_offset +
+ pp->p_size + lp->d_secpercyl - 1) /
+ lp->d_secpercyl - 1);
+ if (pp->p_size % lp->d_secpercyl)
+ putc('*', f);
+ fprintf(f, ")");
+ }
+ fprintf(f, "\n");
}
}
fflush(f);