From 131bc6f0918362e77339eb2f50155843b3488d0d Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 31 Jul 2008 13:07:01 +0000 Subject: [PATCH] Avoid looping forever in _pv_analyze_mda_raw used by pvck. --- WHATS_NEW | 1 + lib/config/config.c | 2 +- lib/format_text/format-text.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 0cad5cba1..a45e46398 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Avoid looping forever in _pv_analyze_mda_raw used by pvck. Change lvchange exit status to indicate if any part of the operation failed. Fix pvchange and pvremove to handle PVs without mdas. Refactor _text_pv_read and always return mda list if requested. diff --git a/lib/config/config.c b/lib/config/config.c index 3166550a5..1fb7e9b05 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -1276,7 +1276,7 @@ unsigned maybe_config_section(const char *str, unsigned len) begin_count = _count_tokens(str, len, TOK_SECTION_B); end_count = _count_tokens(str, len, TOK_SECTION_E); - if (begin_count && end_count && (begin_count - end_count == 0)) + if (begin_count && end_count && (begin_count == end_count)) return 1; else return 0; diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 24188526f..e499af0ba 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -139,7 +139,7 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt, struct raw_locn *rlocn; uint64_t area_start; uint64_t area_size; - uint64_t prev_sector; + uint64_t prev_sector, prev_sector2; uint64_t latest_mrec_offset; int i; uint64_t offset; @@ -184,8 +184,11 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt, offset2 = size2 = 0; i = 0; while (prev_sector != latest_mrec_offset) { + prev_sector2 = prev_sector; prev_sector = _get_prev_sector_circular(area_start, area_size, prev_sector); + if (prev_sector > prev_sector2) + goto_out; /* * FIXME: for some reason, the whole metadata region from * area->start to area->start+area->size is not used. -- 2.43.5