diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amiga/amiga/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/arm32/arm32/disksubr.c | 6 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 9 | ||||
-rw-r--r-- | sys/arch/kbus/kbus/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/mips/mips/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/disksubr.c | 6 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/disksubr.c | 14 | ||||
-rw-r--r-- | sys/arch/sun3/sun3/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/vax/vax/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/wgrisc/wgrisc/disksubr.c | 8 |
15 files changed, 104 insertions, 19 deletions
diff --git a/sys/arch/amiga/amiga/disksubr.c b/sys/arch/amiga/amiga/disksubr.c index 4a75f4a6442..088aa8317b1 100644 --- a/sys/arch/amiga/amiga/disksubr.c +++ b/sys/arch/amiga/amiga/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.17 1998/10/03 21:18:54 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.18 1999/01/08 04:29:04 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.27 1996/10/13 03:06:34 christos Exp $ */ /* @@ -517,6 +517,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { diff --git a/sys/arch/arm32/arm32/disksubr.c b/sys/arch/arm32/arm32/disksubr.c index aea222b325a..9cb3ee1f4c0 100644 --- a/sys/arch/arm32/arm32/disksubr.c +++ b/sys/arch/arm32/arm32/disksubr.c @@ -526,6 +526,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) int labelsector = lp->d_partitions[0].p_offset + LABELSECTOR; int sz; + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + sz = howmany(bp->b_bcount, lp->d_secsize); if (bp->b_blkno + sz > p->p_size) { diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index 16131108550..97e730a708b 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.11 1998/10/04 20:35:16 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.12 1999/01/08 04:29:05 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */ /* @@ -239,6 +239,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* Overwriting disk label? */ if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && (bp->b_flags & B_READ) == 0 && !wlabel) { diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index 7d99c2193f1..a3ae93c54d0 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.35 1998/11/21 20:43:43 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.36 1999/01/08 04:29:06 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -500,6 +500,13 @@ bounds_check_with_label(bp, lp, osdep, wlabel) 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) { diff --git a/sys/arch/kbus/kbus/disksubr.c b/sys/arch/kbus/kbus/disksubr.c index b88ee680f00..52be09fc670 100644 --- a/sys/arch/kbus/kbus/disksubr.c +++ b/sys/arch/kbus/kbus/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.3 1998/10/03 21:18:55 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.4 1999/01/08 04:29:06 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -267,6 +267,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ /* XXX this assumes everything <=LABELSECTOR is label! */ diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c index b541b841147..b4831609618 100644 --- a/sys/arch/mac68k/mac68k/disksubr.c +++ b/sys/arch/mac68k/mac68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.9 1998/10/03 21:18:55 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.10 1999/01/08 04:29:07 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */ /* @@ -650,6 +650,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) int maxsz = p->p_size; int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT; + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ #if 0 /* MF this is crap, especially on swap !! */ diff --git a/sys/arch/mips/mips/disksubr.c b/sys/arch/mips/mips/disksubr.c index 36aee7976bc..28e9f81be00 100644 --- a/sys/arch/mips/mips/disksubr.c +++ b/sys/arch/mips/mips/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.7 1998/11/21 20:43:44 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.8 1999/01/08 04:29:07 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -503,6 +503,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c index b79deca5fcc..b3379f82675 100644 --- a/sys/arch/mvme68k/mvme68k/disksubr.c +++ b/sys/arch/mvme68k/mvme68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.17 1998/10/04 23:27:27 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.18 1999/01/08 04:29:07 millert Exp $ */ /* * Copyright (c) 1995 Dale Rahn. @@ -316,6 +316,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c index 3b0ee3222be..2e860c67755 100644 --- a/sys/arch/mvme88k/mvme88k/disksubr.c +++ b/sys/arch/mvme88k/mvme88k/disksubr.c @@ -300,6 +300,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && diff --git a/sys/arch/pmax/pmax/disksubr.c b/sys/arch/pmax/pmax/disksubr.c index be0c0a0edff..ca225f0de97 100644 --- a/sys/arch/pmax/pmax/disksubr.c +++ b/sys/arch/pmax/pmax/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.15 1998/10/04 20:02:58 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.16 1999/01/08 04:29:09 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.14 1997/01/15 00:55:43 jonathan Exp $ */ /* @@ -333,6 +333,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && diff --git a/sys/arch/powerpc/powerpc/disksubr.c b/sys/arch/powerpc/powerpc/disksubr.c index 227df3182b4..f81d4f2336d 100644 --- a/sys/arch/powerpc/powerpc/disksubr.c +++ b/sys/arch/powerpc/powerpc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.11 1998/10/03 21:18:56 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.12 1999/01/08 04:29:09 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -498,6 +498,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index 1b5c134a8c0..dbbde33fd4f 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.22 1999/01/05 04:29:03 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.23 1999/01/08 04:29:10 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -308,6 +308,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ /* XXX this assumes everything <=LABELSECTOR is label! */ @@ -318,12 +324,6 @@ bounds_check_with_label(bp, lp, osdep, wlabel) goto bad; } - /* 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; diff --git a/sys/arch/sun3/sun3/disksubr.c b/sys/arch/sun3/sun3/disksubr.c index 8f5b69510ee..52ca08c1b23 100644 --- a/sys/arch/sun3/sun3/disksubr.c +++ b/sys/arch/sun3/sun3/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.13 1998/10/03 21:18:56 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.14 1999/01/08 04:29:10 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.14 1996/09/26 18:10:21 gwr Exp $ */ /* @@ -254,6 +254,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) struct partition *p = lp->d_partitions + dkpart(bp->b_dev); int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ /* XXX PR#2598: labelsect is always sector zero. */ diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c index f9f998e24c4..9b82f3cf8b1 100644 --- a/sys/arch/vax/vax/disksubr.c +++ b/sys/arch/vax/vax/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.10 1998/10/03 21:18:56 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.11 1999/01/08 04:29:10 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.13 1997/07/06 22:38:26 ragge Exp $ */ /* @@ -73,6 +73,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + /* overwriting disk label ? */ if (bp->b_blkno + p->p_offset <= labelsect && #if LABELSECTOR != 0 diff --git a/sys/arch/wgrisc/wgrisc/disksubr.c b/sys/arch/wgrisc/wgrisc/disksubr.c index 4161ac28cc4..74421d4cd53 100644 --- a/sys/arch/wgrisc/wgrisc/disksubr.c +++ b/sys/arch/wgrisc/wgrisc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.10 1998/10/03 21:18:57 millert Exp $ */ +/* $OpenBSD: disksubr.c,v 1.11 1999/01/08 04:29:11 millert Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -494,6 +494,12 @@ bounds_check_with_label(bp, lp, osdep, wlabel) LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); + /* avoid division by zero */ + if (lp->d_secpercyl == 0) { + bp->b_error = EINVAL; + goto bad; + } + if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { |