diff options
author | Niels Provos <provos@cvs.openbsd.org> | 1997-04-30 08:40:16 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 1997-04-30 08:40:16 +0000 |
commit | b802dabb54895b9c76d715226dd917e02509c9c5 (patch) | |
tree | 7b2deb962f63a9db7512d21d2b364e74196da88a /sys/arch | |
parent | da25ab991212a8879c03e4b92525aad5fb53e7ed (diff) |
guarantee termination for faked disklabels, no endless loops
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/arc/arc/disksubr.c | 7 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/sys/arch/arc/arc/disksubr.c b/sys/arch/arc/arc/disksubr.c index bab95107c7b..8c12c12f1a2 100644 --- a/sys/arch/arc/arc/disksubr.c +++ b/sys/arch/arc/arc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.12 1997/04/18 20:15:47 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.13 1997/04/30 08:40:15 provos Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -112,12 +112,15 @@ readdisklabel(dev, strat, lp, osdep) unsigned long extoff = 0; int wander = 1; int n = 0; + int loop = 0; /* * Read dos partition table, follow extended partitions. * Map the partitions to disklabel entries i-p */ - while (wander && n < 8) { + while (wander && n < 8 && loop < 8) { + loop++; + /* on finding a extended partition wander further */ wander = 0; diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index f94a3927d0c..5ac2617d8a8 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.21 1997/04/18 20:15:43 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.22 1997/04/30 08:40:11 provos Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -112,12 +112,15 @@ readdisklabel(dev, strat, lp, osdep) unsigned long extoff = 0; int wander = 1; int n = 0; + int loop = 0; /* * Read dos partition table, follow extended partitions. * Map the partitions to disklabel entries i-p */ - while (wander && n < 8) { + while (wander && n < 8 && loop < 8) { + loop++; + /* on finding a extended partition wander further */ wander = 0; |