From 8a6f16ce0dc98f76aa231499bc333e6fad17be5a Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Mon, 9 Jun 2025 10:06:38 +0200 Subject: [PATCH] Fix string2ibpi function Resolves: RHEL-90182 --- ...1.1.0-utils-fix-string2ibpi-function.patch | 32 +++++++++++++++++++ ledmon.spec | 7 +++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 0001-ledmon-1.1.0-utils-fix-string2ibpi-function.patch diff --git a/0001-ledmon-1.1.0-utils-fix-string2ibpi-function.patch b/0001-ledmon-1.1.0-utils-fix-string2ibpi-function.patch new file mode 100644 index 0000000..a398c8f --- /dev/null +++ b/0001-ledmon-1.1.0-utils-fix-string2ibpi-function.patch @@ -0,0 +1,32 @@ +From 740a352626e2ed5d26389200f38323fde9bd84f1 Mon Sep 17 00:00:00 2001 +From: Blazej Kucman +Date: Wed, 16 Apr 2025 12:26:38 +0200 +Subject: [PATCH] utils: Fix string2ibpi function + +string2ibpi does not compare strings correctly, the function uses strncmp, +which in case strings of different lengths, may return incorrect value +if substrings of given max length are identical. In this function whole +strings must be identical. + +Fix is to change strncmp to strcmp. + +Fixes intel/ledmon#259 +Fixes: 94818457f615 ("Add struct for mapping ibpi statuses to strings. (#211)") +Signed-off-by: Blazej Kucman +--- + src/lib/utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/lib/utils.c b/src/lib/utils.c +index bad35eb4..2fe0f764 100644 +--- a/src/lib/utils.c ++++ b/src/lib/utils.c +@@ -765,7 +765,7 @@ enum led_ibpi_pattern string2ibpi(const char *name) + if (!input_name) + continue; + +- if (strncmp(input_name, name, strlen(input_name)) == 0) ++ if (strcmp(input_name, name) == 0) + return ipbi_names[i].ibpi; + } + diff --git a/ledmon.spec b/ledmon.spec index 672b0f4..2b5e6f6 100644 --- a/ledmon.spec +++ b/ledmon.spec @@ -1,11 +1,13 @@ Summary: Enclosure LED Utilities Name: ledmon Version: 1.1.0 -Release: 1%{?dist} +Release: 2%{?dist} License: GPL-2.0-only AND LGPL-2.1-only URL: https://github.com/intel/ledmon Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch: 0001-ledmon-1.1.0-utils-fix-string2ibpi-function.patch + BuildRequires: autoconf automake BuildRequires: autoconf-archive BuildRequires: gcc make @@ -87,6 +89,9 @@ autoreconf -fiv %{_libdir}/pkgconfig/%{name}.pc %changelog +* Mon Jun 09 2025 Jan Macku - 1.1.0-2 +- Fix string2ibpi function (RHEL-90182) + * Tue Nov 12 2024 Jan Macku - 1.1.0-1 - update to 1.1.0