summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2017-07-19 14:54:29 +0000
committerderaadt <deraadt@openbsd.org>2017-07-19 14:54:29 +0000
commitef4c4962c2b458374a9cfe46c361d016140a598f (patch)
treef7c033e3d657c0cebfec2a652afed2d1623612d5
parentAdd a enter_ddb() "accessop" to wsdisplay(4) to allow KMS drivers to bypass (diff)
downloadwireguard-openbsd-ef4c4962c2b458374a9cfe46c361d016140a598f.tar.xz
wireguard-openbsd-ef4c4962c2b458374a9cfe46c361d016140a598f.zip
Avoid additional div0 in case both ntracks & nsectors passed in
via ioctl are 0. Noticed by bluhm ok bluhm millert
-rw-r--r--sys/dev/vnd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 61f58ae9e7f..ba8db67155e 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.164 2017/07/19 13:38:05 deraadt Exp $ */
+/* $OpenBSD: vnd.c,v 1.165 2017/07/19 14:54:29 deraadt Exp $ */
/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
@@ -219,7 +219,8 @@ vndgetdisklabel(dev_t dev, struct vnd_softc *sc, struct disklabel *lp,
lp->d_nsectors = sc->sc_nsectors;
lp->d_ntracks = sc->sc_ntracks;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
- lp->d_ncylinders = sc->sc_size / lp->d_secpercyl;
+ if (lp->d_secpercyl)
+ lp->d_ncylinders = sc->sc_size / lp->d_secpercyl;
strncpy(lp->d_typename, "vnd device", sizeof(lp->d_typename));
lp->d_type = DTYPE_VND;