Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > main-release-src > by-pkgid > 8e464684ea2b3924306d1de83199d544 > files > 27

util-linux-ng-2.17.1-5mdv2010.1.src.rpm

From 046959cca19be0b1e489bae66314fcf6047fe4c5 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@canonical.com>
Date: Sat, 13 Mar 2010 00:46:35 +0000
Subject: [PATCH] libblkid: fix infinite loop when probe chain bails out early

The superblocks probe bails out early with no results in some cases.  If
this happens, blkid_do_probe needs to go to the next chain, rather than
entering an infinite loop calling superblocks_probe over and over again.

[kzak@redhat.com: - print debug message always when leaving
                    superblocks_probe()]

Addresses: https://bugs.launchpad.net/bugs/528073
Signed-off-by: Colin Watson <cjwatson@canonical.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 shlibs/blkid/src/probe.c                   |    6 ++++--
 shlibs/blkid/src/superblocks/superblocks.c |    4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index 6d61386..ab1c8d5 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -721,10 +721,12 @@ int blkid_do_probe(blkid_probe pr)
 		/* we go to the next chain only when the previous probing
 		 * result was nothing (rc == 1) and when the current chain is
 		 * disabled or we are at end of the current chain (chain->idx +
-		 * 1 == sizeof chain)
+		 * 1 == sizeof chain) or the current chain bailed out right at
+		 * the start (chain->idx == -1)
 		 */
 		else if (rc == 1 && (chn->enabled == FALSE ||
-				     chn->idx + 1 == chn->driver->nidinfos)) {
+				     chn->idx + 1 == chn->driver->nidinfos ||
+				     chn->idx == -1)) {
 
 			int idx = chn->driver->id + 1;
 
diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c
index 56b334d..05668e1 100644
--- a/shlibs/blkid/src/superblocks/superblocks.c
+++ b/shlibs/blkid/src/superblocks/superblocks.c
@@ -315,7 +315,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
 		/* Ignore very very small block devices or regular files (e.g.
 		 * extended partitions). Note that size of the UBI char devices
 		 * is 1 byte */
-		return 1;
+		goto nothing;
 
 	i = chn->idx + 1;
 
@@ -396,6 +396,8 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
 			id->name, chn->idx));
 		return 0;
 	}
+
+nothing:
 	DBG(DEBUG_LOWPROBE,
 		printf("<-- leaving probing loop (failed) [SUBLKS idx=%d]\n",
 		chn->idx));
-- 
1.7.1