summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-08-10 12:14:19 +0000
committerderaadt <deraadt@openbsd.org>1996-08-10 12:14:19 +0000
commitcf6e0f4e989bea897fcdbbd72dbd32a3c36fb8f4 (patch)
tree27160e4a82686ec55b2115c1a138b6aec3eb9783
parentsys/dirent.h (diff)
downloadwireguard-openbsd-cf6e0f4e989bea897fcdbbd72dbd32a3c36fb8f4.tar.xz
wireguard-openbsd-cf6e0f4e989bea897fcdbbd72dbd32a3c36fb8f4.zip
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);