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

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