From 9a318a986cf9007172541e7dc42723c3378fd5a3 Mon Sep 17 00:00:00 2001 From: Than Ngo Date: Tue, 30 Jan 2024 13:44:18 +0100 Subject: [PATCH] Resolves: RHEL-23015, prevent adding duplicate entries --- .libvpd.metadata | 1 + libvpd-prevent-adding-duplicate-entries.patch | 40 +++++++++++++++++++ libvpd.spec | 9 ++++- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .libvpd.metadata create mode 100644 libvpd-prevent-adding-duplicate-entries.patch diff --git a/.libvpd.metadata b/.libvpd.metadata new file mode 100644 index 0000000..1111635 --- /dev/null +++ b/.libvpd.metadata @@ -0,0 +1 @@ +17fcca6874e97490e2b44868b50bb1e2c456dc35 libvpd-2.2.9.tar.gz diff --git a/libvpd-prevent-adding-duplicate-entries.patch b/libvpd-prevent-adding-duplicate-entries.patch new file mode 100644 index 0000000..5595d29 --- /dev/null +++ b/libvpd-prevent-adding-duplicate-entries.patch @@ -0,0 +1,40 @@ +commit 34ab92ebc818bc5b356f1d297868512225493eca +Author: Sathvika Vasireddy +Date: Thu Nov 9 02:37:36 2023 +0530 + + libvpd: Prevent adding duplicate entries in addDeviceSpecific() function + + Currently, addDeviceSpecific() adds new 'DataItem' to the + 'mDeviceSpecific' vector without checking for duplicates. This + vector can be further used by the front end tools to list vpd + information. If this vector has duplicate entries, then vpd + information for a specific device is listed more than once. + + To fix this, prevent duplicate entries with the same 'ac' value + from being stored in the vector. Check if a 'DataItem' with + the same ac value already exists in the vector, and add the new + object to the vector only if no matching item is found. + + Signed-off-by: Sathvika Vasireddy + Signed-off-by: Mahesh Salgaonkar + +diff --git a/src/component.cpp b/src/component.cpp +index 44208ac..a945fc1 100644 +--- a/src/component.cpp ++++ b/src/component.cpp +@@ -937,7 +937,6 @@ lderr: + d->ac = ac; + d->humanName = humanName; + d->setValue( val, lvl, __FILE__, __LINE__ ); +-#if 0 + + /* + * There can be multiple records with the 'CL' key. +@@ -952,7 +951,6 @@ lderr: + if( (*i)->ac == ac ) + return; //Failed to add - already present + } +-#endif + + mDeviceSpecific.push_back( d ); + } diff --git a/libvpd.spec b/libvpd.spec index 989319d..efb1d4a 100644 --- a/libvpd.spec +++ b/libvpd.spec @@ -1,11 +1,13 @@ Name: libvpd Version: 2.2.9 -Release: 1%{?dist} +Release: 2%{?dist} Summary: VPD Database access library for lsvpd License: LGPLv2+ URL: https://github.com/power-ras/%{name}/releases Source: https://github.com/power-ras/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz +# Prevent adding duplicate entries +Patch0: libvpd-prevent-adding-duplicate-entries.patch BuildRequires: gcc-c++ BuildRequires: sqlite-devel zlib-devel libstdc++-devel libtool @@ -24,7 +26,7 @@ Requires: %{name} = %{version}-%{release} sqlite-devel pkgconfig Contains header files for building with libvpd. %prep -%setup -q +%autosetup -p1 %build export CXXFLAGS="-std=c++14 $RPM_OPT_FLAGS" @@ -56,6 +58,9 @@ find %{buildroot} -type f -name "*.la" -delete %{_libdir}/pkgconfig/libvpd_cxx-2.pc %changelog +* Tue Jan 30 2024 Than Ngo - 2.2.9-2 +- Resolves: RHEL-23015, prevent adding duplicate entries + * Fri May 06 2022 Than Ngo - 2.2.9-1 - Resolves: #2051288, rebase to 2.2.9