Blame SOURCES/0002-thin_show_metadata-Fix-out-of-bounds-access.patch

4ee10e
From 691a0237809b5364117446a8a9b0cceeb0a747c1 Mon Sep 17 00:00:00 2001
4ee10e
From: Ming-Hung Tsai <mtsai@redhat.com>
4ee10e
Date: Tue, 1 Jun 2021 11:24:11 +0800
4ee10e
Subject: [PATCH 02/10] [thin_show_metadata] Fix out-of-bounds access
4ee10e
4ee10e
---
4ee10e
 thin-provisioning/thin_show_metadata.cc | 3 ++-
4ee10e
 1 file changed, 2 insertions(+), 1 deletion(-)
4ee10e
4ee10e
diff --git a/thin-provisioning/thin_show_metadata.cc b/thin-provisioning/thin_show_metadata.cc
4ee10e
index bdbab3f..dbc7a80 100644
4ee10e
--- a/thin-provisioning/thin_show_metadata.cc
4ee10e
+++ b/thin-provisioning/thin_show_metadata.cc
4ee10e
@@ -206,7 +206,8 @@ namespace {
4ee10e
 
4ee10e
 		void run() {
4ee10e
 			auto line_length = 80;
4ee10e
-			for (block_address b = 0; b < 2000; b++) {
4ee10e
+			block_address nr_blocks = std::min<block_address>(2000, bm_.get_nr_blocks());
4ee10e
+			for (block_address b = 0; b < nr_blocks; b++) {
4ee10e
 				block_manager::read_ref rr = bm_.read_lock(b);
4ee10e
 
4ee10e
 				if (!(b % line_length)) {
4ee10e
-- 
4ee10e
1.8.3.1
4ee10e