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

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