From b802dabb54895b9c76d715226dd917e02509c9c5 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Wed, 30 Apr 1997 08:40:16 +0000 Subject: guarantee termination for faked disklabels, no endless loops --- sys/arch/arc/arc/disksubr.c | 7 +++++-- 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; -- cgit v1.2.3