diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-07-19 14:54:30 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-07-19 14:54:30 +0000 |
commit | b8e94302f5da807ad88748b4bb7da5f75a40cc05 (patch) | |
tree | 3995b7d06231e813c45eb586bfb128d6453a7cdb /sys/dev/vnd.c | |
parent | 5bfa92540d5e3d2a68895b4f754be2625844d96c (diff) |
Avoid additional div0 in case both ntracks & nsectors passed in
via ioctl are 0.
Noticed by bluhm
ok bluhm millert
Diffstat (limited to 'sys/dev/vnd.c')
-rw-r--r-- | sys/dev/vnd.c | 5 |
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; |