diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-10-21 20:10:40 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-10-21 20:10:40 +0000 |
commit | 028e50e88381ac41692fb30181b338f5b071050a (patch) | |
tree | 491f1da9c6fa9edfe3c7fb72f0ff3bf9df7d0823 | |
parent | 414b81d3b17102a765dc8117c456a89585a74d53 (diff) |
Don't try to spoof 0 length DOS MBR/EBR partitions. By skipping
partitions with 0 in the length field we don't need to test for
and skip partitions that are all zeros. Eliminating that code
allows elimination of a local pointer.
"0 length partitions are definately dead" deraadt@
-rw-r--r-- | sys/arch/alpha/alpha/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/arm/arm/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/hppa64/hppa64/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/landisk/landisk/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 21 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/disksubr.c | 21 |
11 files changed, 66 insertions, 165 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index ad25008c37f..d15e4613535 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.62 2006/10/21 16:01:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.63 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -222,7 +222,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) struct partition *pp; unsigned long extoff = 0; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -307,25 +307,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c index ec839393506..dbc07be3e80 100644 --- a/sys/arch/amd64/amd64/disksubr.c +++ b/sys/arch/amd64/amd64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.23 2006/10/21 16:01:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.24 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -73,7 +73,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) unsigned long extoff = 0; struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -166,25 +166,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c index 7e3ffe505a3..7aa73a25b29 100644 --- a/sys/arch/arm/arm/disksubr.c +++ b/sys/arch/arm/arm/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.21 2006/10/21 16:01:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.22 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -73,7 +73,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) unsigned long extoff = 0; struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -166,25 +166,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index 6e6f74fe9c8..4ce153e11c5 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.12 2006/10/21 16:01:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.13 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -73,7 +73,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) unsigned long extoff = 0; struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -166,25 +166,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c index 14dd7cdc355..df031b5167f 100644 --- a/sys/arch/hppa/hppa/disksubr.c +++ b/sys/arch/hppa/hppa/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.42 2006/10/21 16:01:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.43 2006/10/21 20:10:39 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -225,7 +225,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) struct partition *pp; unsigned long extoff = 0; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -310,25 +310,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c index 3366bdbefd5..95501371a51 100644 --- a/sys/arch/hppa64/hppa64/disksubr.c +++ b/sys/arch/hppa64/hppa64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.25 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.26 2006/10/21 20:10:39 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -221,7 +221,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) struct partition *pp; unsigned long extoff = 0; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -306,25 +306,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index 2d6bf5beab9..c74021103a7 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.65 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.66 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -69,7 +69,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, unsigned long extoff = 0; struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -162,25 +162,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c index a1667b767b8..ddf101269f2 100644 --- a/sys/arch/landisk/landisk/disksubr.c +++ b/sys/arch/landisk/landisk/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.9 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.10 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -73,7 +73,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) unsigned long extoff = 0; struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -166,25 +166,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c index 2b84644dd97..1def3fb4cce 100644 --- a/sys/arch/macppc/macppc/disksubr.c +++ b/sys/arch/macppc/macppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.31 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.32 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -72,7 +72,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), unsigned long extoff = 0; struct buf *bp; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; char *s; int dospartoff, cyl, i, ourpart = -1; int wander = 1, loop = 0; @@ -252,25 +252,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index a941842d14d..5d75837567b 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.31 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.32 2006/10/21 20:10:39 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -229,7 +229,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) struct partition *pp; unsigned long extoff = 0; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -314,25 +314,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c index cda3da49b56..9cfd38a004a 100644 --- a/sys/arch/mvmeppc/mvmeppc/disksubr.c +++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.27 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.28 2006/10/21 20:10:39 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -76,7 +76,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) unsigned long extoff = 0; struct buf *bp; daddr_t part_blkno = DOSBBSECTOR; - char *msg = NULL, *cp; + char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; int wander = 1, n = 0, loop = 0; @@ -169,25 +169,16 @@ donot: continue; if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (letoh32(dp2->dp_size)) - pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_size) == 0) + continue; if (letoh32(dp2->dp_start)) pp->p_offset = letoh32(dp2->dp_start) + part_blkno; + pp->p_size = letoh32(dp2->dp_size); + switch (dp2->dp_typ) { case DOSPTYP_UNUSED: - for (cp = (char *)dp2; - cp < (char *)(dp2 + 1); cp++) - if (*cp) - break; - /* - * Was it all zeroes? If so, it is - * an unused entry that we don't - * want to show. - */ - if (cp == (char *)(dp2 + 1)) - continue; pp->p_fstype = FS_UNUSED; n++; break; |