From ff35109c59958072cf0b9c3aea90bfbfe112bb11 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 24 Jan 1997 11:17:09 +0000 Subject: [PATCH] do not build fake disklabel partitions for MBR partitions that have out-of-range start/size fields --- sys/arch/arc/arc/disksubr.c | 4 +++- sys/arch/i386/i386/disksubr.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/arch/arc/arc/disksubr.c b/sys/arch/arc/arc/disksubr.c index 034f63be1f0..6472fe44dd1 100644 --- a/sys/arch/arc/arc/disksubr.c +++ b/sys/arch/arc/arc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.7 1997/01/14 00:46:42 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.8 1997/01/24 11:17:12 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -161,6 +161,8 @@ readdisklabel(dev, strat, lp, osdep) * a fake label in which m/n/o/p are MBR partitions 0/1/2/3 */ for (dp2=dp, i=0; i < NDOSPART; i++, dp2++) { + if (dp2->dp_start + dp2->dp_size > lp->d_nsectors) + continue; lp->d_partitions[12+i].p_size = dp2->dp_size; lp->d_partitions[12+i].p_offset = dp2->dp_start; for (ip = fat_types; *ip != -1; ip++) { diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index 26cfdd13c28..9064e1f44be 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.16 1997/01/14 00:46:45 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.17 1997/01/24 11:17:09 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -161,6 +161,8 @@ readdisklabel(dev, strat, lp, osdep) * a fake label in which m/n/o/p are MBR partitions 0/1/2/3 */ for (dp2=dp, i=0; i < NDOSPART; i++, dp2++) { + if (dp2->dp_start + dp2->dp_size > lp->d_nsectors) + continue; lp->d_partitions[12+i].p_size = dp2->dp_size; lp->d_partitions[12+i].p_offset = dp2->dp_start; for (ip = fat_types; *ip != -1; ip++) { -- 2.20.1