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

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