diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-01-05 04:29:04 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-01-05 04:29:04 +0000 |
commit | a2c265cd53f9ad094038a1c234f962fd584168a1 (patch) | |
tree | 0a0c3ce35df2b2285b6c02dc49f4040ef2b12309 /sys/arch/alpha | |
parent | 245bd18b98b49158bfffe447accb65616ac74c50 (diff) |
be extra careful to not divide by zero; more arches to come
Diffstat (limited to 'sys/arch/alpha')
-rw-r--r-- | sys/arch/alpha/alpha/disksubr.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index 0c247eb559d..36219e12429 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.26 1998/11/23 03:35:56 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.27 1999/01/05 04:29:03 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -343,6 +343,15 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) int dospartoff, cyl, i, ourpart = -1; dev_t dev; + if (lp->d_secpercyl == 0) { + msg = "invalid label, d_secpercyl == 0"; + return (msg); + } + if (lp->d_secsize == 0) { + msg = "invalid label, d_secsize == 0"; + return (msg); + } + /* do dos partitions in the process of getting disklabel? */ dospartoff = 0; cyl = I386_LABELSECTOR / lp->d_secpercyl; @@ -745,6 +754,13 @@ bounds_check_with_label(bp, lp, osdep, wlabel) lp) + osdep->labelsector; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + + /* beyond partition? */ if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { |