Blame SOURCES/sysstat-12.5.4-bz2080650.patch

611499
From 398585bfe7b1340d41143f50dfc868ef8ab9a5e4 Mon Sep 17 00:00:00 2001
611499
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= <lzaoral@redhat.com>
611499
Date: Tue, 21 Feb 2023 12:43:42 +0100
611499
Subject: [PATCH] Tools that take --dec=X option should only accept digits
611499
MIME-Version: 1.0
611499
Content-Type: text/plain; charset=UTF-8
611499
Content-Transfer-Encoding: 8bit
611499
611499
Right now the argument of --dec is passed to atoi(3) which returns 0
611499
on conversion error.  Therefore, --dec=A was not rejected and was
611499
equivalent to --dec=0 by mistake.
611499
611499
Signed-off-by: Lukáš Zaoral <lzaoral@redhat.com>
611499
---
611499
 cifsiostat.c | 5 +++++
611499
 iostat.c     | 5 +++++
611499
 mpstat.c     | 5 +++++
611499
 pidstat.c    | 5 +++++
611499
 sar.c        | 6 ++++++
611499
 5 files changed, 26 insertions(+)
611499
611499
diff --git a/cifsiostat.c b/cifsiostat.c
611499
index 375b1ff..849583b 100644
611499
--- a/cifsiostat.c
611499
+++ b/cifsiostat.c
611499
@@ -522,6 +522,11 @@ int main(int argc, char **argv)
611499
 		}
611499
 
611499
 		else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
611499
+			/* Check that the argument is a digit */
611499
+			if (!isdigit(argv[opt][6])) {
611499
+				usage(argv[0]);
611499
+			}
611499
+
611499
 			/* Get number of decimal places */
611499
 			dplaces_nr = atoi(argv[opt] + 6);
611499
 			if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
611499
diff --git a/iostat.c b/iostat.c
611499
index 1d7ea3c..7ac56ef 100644
611499
--- a/iostat.c
611499
+++ b/iostat.c
611499
@@ -2142,6 +2142,11 @@ int main(int argc, char **argv)
611499
 #endif
611499
 
611499
 		else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
611499
+			/* Check that the argument is a digit */
611499
+			if (!isdigit(argv[opt][6])) {
611499
+				usage(argv[0]);
611499
+			}
611499
+
611499
 			/* Get number of decimal places */
611499
 			dplaces_nr = atoi(argv[opt] + 6);
611499
 			if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
611499
diff --git a/mpstat.c b/mpstat.c
611499
index 90d6226..5045e45 100644
611499
--- a/mpstat.c
611499
+++ b/mpstat.c
611499
@@ -2221,6 +2221,11 @@ int main(int argc, char **argv)
611499
 	while (++opt < argc) {
611499
 
611499
 		if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
611499
+			/* Check that the argument is a digit */
611499
+			if (!isdigit(argv[opt][6])) {
611499
+				usage(argv[0]);
611499
+			}
611499
+
611499
 			/* Get number of decimal places */
611499
 			dplaces_nr = atoi(argv[opt] + 6);
611499
 			if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
611499
diff --git a/pidstat.c b/pidstat.c
611499
index 21fed6c..d550605 100644
611499
--- a/pidstat.c
611499
+++ b/pidstat.c
611499
@@ -2633,6 +2633,11 @@ int main(int argc, char **argv)
611499
 		}
611499
 
611499
 		else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
611499
+			/* Check that the argument is a digit */
611499
+			if (!isdigit(argv[opt][6])) {
611499
+				usage(argv[0]);
611499
+			}
611499
+
611499
 			/* Get number of decimal places */
611499
 			dplaces_nr = atoi(argv[opt] + 6);
611499
 			if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
611499
diff --git a/sar.c b/sar.c
611499
index 4f06172..7691793 100644
611499
--- a/sar.c
611499
+++ b/sar.c
611499
@@ -28,6 +28,7 @@
611499
 #include <errno.h>
611499
 #include <signal.h>
611499
 #include <sys/stat.h>
611499
+#include <ctype.h>
611499
 
611499
 #include "version.h"
611499
 #include "sa.h"
611499
@@ -1372,6 +1373,11 @@ int main(int argc, char **argv)
611499
 		}
611499
 
611499
 		else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
611499
+			/* Check that the argument is a digit */
611499
+			if (!isdigit(argv[opt][6])) {
611499
+				usage(argv[0]);
611499
+			}
611499
+
611499
 			/* Get number of decimal places */
611499
 			dplaces_nr = atoi(argv[opt] + 6);
611499
 			if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
611499
-- 
611499
2.39.2
611499