Blame SOURCES/bz2109159-storage_mon-2-fix-specified-scores-count.patch

98dd5d
From a68957e8f1e8169438acf5a4321f47ed7d8ceec1 Mon Sep 17 00:00:00 2001
98dd5d
From: Fujii Masao <fujii@postgresql.org>
98dd5d
Date: Tue, 19 Jul 2022 20:28:38 +0900
98dd5d
Subject: [PATCH] storage_mon: Fix bug in checking of number of specified
98dd5d
 scores.
98dd5d
98dd5d
Previously specifying the maximum allowed number (MAX_DEVICES, currently 25)
98dd5d
of devices and scores as arguments could cause storage_mon to fail unexpectedly
98dd5d
with the error message "too many scores, max is 25". This issue happened
98dd5d
because storage_mon checked whether the number of specified scores
98dd5d
exceeded the upper limit by using the local variable "device_count" indicating
98dd5d
the number of specified devices (not scores). So after the maximum number
98dd5d
of devices arguments were interpreted, the appearance of next score argument
98dd5d
caused the error even when the number of interpreted scores arguments had
98dd5d
not exceeded the maximum.
98dd5d
98dd5d
This patch fixes storage_mon so that it uses the local variable "score_count"
98dd5d
indicating the number of specified scores, to check whether arguments for
98dd5d
scores are specified more than the upper limit.
98dd5d
---
98dd5d
 tools/storage_mon.c | 2 +-
98dd5d
 1 file changed, 1 insertion(+), 1 deletion(-)
98dd5d
98dd5d
diff --git a/tools/storage_mon.c b/tools/storage_mon.c
98dd5d
index 3c82d5ee8..c749076c2 100644
98dd5d
--- a/tools/storage_mon.c
98dd5d
+++ b/tools/storage_mon.c
98dd5d
@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
98dd5d
 				}
98dd5d
 				break;
98dd5d
 			case 's':
98dd5d
-				if (device_count < MAX_DEVICES) {
98dd5d
+				if (score_count < MAX_DEVICES) {
98dd5d
 					int score = atoi(optarg);
98dd5d
 					if (score < 1 || score > 10) {
98dd5d
 						fprintf(stderr, "Score must be between 1 and 10 inclusive\n");