summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2006-08-20 03:14:22 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2006-08-20 03:14:22 +0000
commit6390d7da0774617788a856170a04b6b2fd36ac96 (patch)
tree4da516253ee4708b2fd636fdb5286382a911ff2e /sys/arch
parent2878160085960b88ce50f3bf1e3ad0b05bc43789 (diff)
When spoofing an MSDOS disklabel, don't create partitions with a final
block past d_secperunit. Fixes devices where bogus partitions with a starting offset > d_secperunit were created. e.g. floppies formatted by Caldera DR-DOS. ok pedro@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/alpha/disksubr.c7
-rw-r--r--sys/arch/amd64/amd64/disksubr.c7
-rw-r--r--sys/arch/arm/arm/disksubr.c7
-rw-r--r--sys/arch/aviion/aviion/disksubr.c7
-rw-r--r--sys/arch/hppa/hppa/disksubr.c7
-rw-r--r--sys/arch/hppa64/hppa64/disksubr.c7
-rw-r--r--sys/arch/i386/i386/disksubr.c7
-rw-r--r--sys/arch/macppc/macppc/disksubr.c7
-rw-r--r--sys/arch/mips64/mips64/disksubr.c7
-rw-r--r--sys/arch/mvmeppc/mvmeppc/disksubr.c7
10 files changed, 50 insertions, 20 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c
index 75be95137ea..60e2b4c054c 100644
--- a/sys/arch/alpha/alpha/disksubr.c
+++ b/sys/arch/alpha/alpha/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.51 2006/08/17 19:02:15 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.52 2006/08/20 03:14:21 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -316,10 +316,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c
index 6a614a1073d..4131dd5d64d 100644
--- a/sys/arch/amd64/amd64/disksubr.c
+++ b/sys/arch/amd64/amd64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.11 2006/08/17 10:34:14 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.12 2006/08/20 03:14:21 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -173,10 +173,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c
index adc93c3ef8d..0887fd4c2b3 100644
--- a/sys/arch/arm/arm/disksubr.c
+++ b/sys/arch/arm/arm/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.11 2006/08/17 10:34:14 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.12 2006/08/20 03:14:21 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -172,10 +172,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c
index 26399e60bbc..f9ae4a097a4 100644
--- a/sys/arch/aviion/aviion/disksubr.c
+++ b/sys/arch/aviion/aviion/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.4 2006/08/17 10:34:14 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.5 2006/08/20 03:14:21 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -162,10 +162,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c
index 8678d85cd28..404ec4adb4c 100644
--- a/sys/arch/hppa/hppa/disksubr.c
+++ b/sys/arch/hppa/hppa/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.31 2006/08/18 00:39:17 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.32 2006/08/20 03:14:21 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -319,10 +319,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c
index 88aa5bdf588..937a610adc0 100644
--- a/sys/arch/hppa64/hppa64/disksubr.c
+++ b/sys/arch/hppa64/hppa64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.14 2006/08/18 00:39:17 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.15 2006/08/20 03:14:21 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -315,10 +315,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c
index fe6fa1de26c..a1c63891eb1 100644
--- a/sys/arch/i386/i386/disksubr.c
+++ b/sys/arch/i386/i386/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.53 2006/08/17 10:34:14 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.54 2006/08/20 03:14:21 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -173,10 +173,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c
index bd0040b570a..de962013ae6 100644
--- a/sys/arch/macppc/macppc/disksubr.c
+++ b/sys/arch/macppc/macppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.20 2006/08/17 10:34:14 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.21 2006/08/20 03:14:21 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -260,10 +260,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c
index 24493a09db0..9f75b334511 100644
--- a/sys/arch/mips64/mips64/disksubr.c
+++ b/sys/arch/mips64/mips64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.20 2006/08/18 00:39:17 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.21 2006/08/20 03:14:21 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -323,10 +323,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);
diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c
index d416119212f..b25418fd5ef 100644
--- a/sys/arch/mvmeppc/mvmeppc/disksubr.c
+++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.16 2006/08/17 10:34:14 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.17 2006/08/20 03:14:21 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -176,10 +176,13 @@ donot:
*/
for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
+ u_int64_t blkno = (u_int64_t)part_blkno +
+ (u_int64_t)letoh32(dp2->dp_start) +
+ (u_int64_t)letoh32(dp2->dp_size);
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (blkno > lp->d_secperunit)
continue;
if (letoh32(dp2->dp_size))
pp->p_size = letoh32(dp2->dp_size);