From 10b6f14b9652a7a3307886f085e480c387a729a9 Mon Sep 17 00:00:00 2001 From: Yang Yanchao Date: Thu, 24 Feb 2022 10:56:57 +0800 Subject: [PATCH] dmidecode: Fix crash with -u option Signed-off-by: Yang Yanchao (cherry picked from commit 57e2eac7fbe4e99500bc603a56aadf3f784d3b8e) --- dmidecode-Fix-crash-with-u-option.patch | 34 +++++++++++++++++++++++++ dmidecode.spec | 7 ++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 dmidecode-Fix-crash-with-u-option.patch diff --git a/dmidecode-Fix-crash-with-u-option.patch b/dmidecode-Fix-crash-with-u-option.patch new file mode 100644 index 0000000..3a271b6 --- /dev/null +++ b/dmidecode-Fix-crash-with-u-option.patch @@ -0,0 +1,34 @@ +From 11e134e54d15e67a64c39a623f492a28df922517 Mon Sep 17 00:00:00 2001 +From: Jean Delvare +Date: Tue, 19 Jan 2021 16:26:01 +0100 +Subject: [PATCH] dmidecode: Fix crash with -u option + +A segmentation fault was reported with option -u. Turns out to be a +stupid thinko where the buffer offset was reset at the wrong loop +depth. + +Reported-by: Jerry Hoemann +Fixes: da06888d08b9 ("dmidecode: Use the print helpers in dump mode too") +Signed-off-by: Jean Delvare +--- + dmidecode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dmidecode.c b/dmidecode.c +index 572cb1a..69ea0e8 100644 +--- a/dmidecode.c ++++ b/dmidecode.c +@@ -248,9 +248,9 @@ static void dmi_dump(const struct dmi_header *h) + { + int j, l = strlen(s) + 1; + +- off = 0; + for (row = 0; row < ((l - 1) >> 4) + 1; row++) + { ++ off = 0; + for (j = 0; j < 16 && j < l - (row << 4); j++) + off += sprintf(raw_data + off, + j ? " %02X" : "%02X", +-- +2.33.0 + diff --git a/dmidecode.spec b/dmidecode.spec index 85b5ad1..4a4b0d9 100644 --- a/dmidecode.spec +++ b/dmidecode.spec @@ -1,6 +1,6 @@ Name: dmidecode Version: 3.3 -Release: 2 +Release: 3 Epoch: 1 Summary: DMI data report tool @@ -8,6 +8,8 @@ License: GPLv2+ URL: https://www.nongnu.org/dmidecode/ Source0: http://download.savannah.gnu.org/releases/dmidecode/%{name}-%{version}.tar.xz +Patch1: dmidecode-Fix-crash-with-u-option.patch + Patch6000: bugfix-compat_uuid.patch BuildRequires: make gcc xz @@ -50,6 +52,9 @@ make %{?_smp_mflags} CFLAGS="%{__global_cflags}" LDFLAGS="%{__global_ldflags}" %{_mandir}/man8/*.8.gz %changelog +* Thu Feb 24 2022 Yang Yanchao - 3.3-3 +- dmidecode: Fix crash with -u option + * Sat Jan 29 2022 Yang Yanchao - 3.3-2 - add command --compat-uuid -- Gitee