!13 backport Fix Segmentation Fault in Dell Precision T1700

From: @liyy9 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
This commit is contained in:
openeuler-ci-bot 2023-10-20 08:05:38 +00:00 committed by Gitee
commit 43b8349558
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 75 additions and 2 deletions

View File

@ -0,0 +1,25 @@
From d849a11447ace88fe505460178dc0b74f580c0d7 Mon Sep 17 00:00:00 2001
From: Mario Limonciello <mario.limonciello@dell.com>
Date: Wed, 27 Mar 2019 12:29:44 -0500
Subject: [PATCH] Fix a segfault if unable to find service token (Fixes: #57)
---
src/libsmbios_c/system_info/service_tag.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libsmbios_c/system_info/service_tag.c b/src/libsmbios_c/system_info/service_tag.c
index b2b0af6..b1aec53 100644
--- a/src/libsmbios_c/system_info/service_tag.c
+++ b/src/libsmbios_c/system_info/service_tag.c
@@ -374,6 +374,8 @@ int setServiceTagUsingCMOSToken(const char *newTag, const char *pass_ascii, cons
// Step 2: reset checksum
fnprintf("- csum ");
s = token_get_smbios_struct(Cmos_Service_Token);
+ if (!s)
+ goto out;
indexPort = ((struct indexed_io_access_structure*)s)->indexPort;
dataPort = ((struct indexed_io_access_structure*)s)->dataPort;
location = ((struct indexed_io_token *)token_get_ptr(Cmos_Service_Token))->location;
--
2.33.0

View File

@ -0,0 +1,43 @@
From 0cd2e55565cd1c1b8f2bc14fafb690083e278923 Mon Sep 17 00:00:00 2001
From: Mario Limonciello <mario.limonciello@dell.com>
Date: Wed, 27 Mar 2019 12:58:01 -0500
Subject: [PATCH] Encode string used when setting strings (Fixes: #57)
---
src/bin/smbios-sys-info | 2 +-
src/py-cli/cli.py | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/bin/smbios-sys-info b/src/bin/smbios-sys-info
index 07a82ea..b789300 100755
--- a/src/bin/smbios-sys-info
+++ b/src/bin/smbios-sys-info
@@ -117,7 +117,7 @@ def main():
print()
print(_("Setting new tag value: %s") % options.set)
fn = info_list[ options.taglist[0] ][2]
- fn(options.set, options.password_ascii, options.password_scancode)
+ fn(options.set.encode(), options.password_ascii, options.password_scancode)
except (smbios.TableParseError,) as e:
exit_code=3
diff --git a/src/py-cli/cli.py b/src/py-cli/cli.py
index c865646..50b479d 100644
--- a/src/py-cli/cli.py
+++ b/src/py-cli/cli.py
@@ -75,8 +75,12 @@ def setup_std_options(options):
if options.password is not None:
options.password_scancode = braindead_asc_to_scancode(options.password)
options.password_ascii = options.password
+ if options.password_ascii:
+ options.password_ascii = options.password_ascii.encode('utf-8')
if options.raw:
options.password_scancode = options.password
+ if options.password_scancode:
+ options.password_scancode = options.password_scancode.encode('utf-8')
if getattr(options, "security_key", None) is not None:
options.security_key = int(options.security_key, 0)
--
2.33.0

View File

@ -4,14 +4,16 @@
Name: libsmbios
Version: 2.4.2
Release: 4
Release: 5
Summary: Interface with the SMBIOS tables
License: GPLv2+ or OSL 2.1
URL: https://github.com/dell/libsmbios
Source0: https://github.com/dell/libsmbios/archive/v%{version}/libsmbios-%{version}.tar.gz
Patch0001: 0001-libsmbios-fix-more-places-with-loop-iterators-with-b.patch
Patch0002: 0002-Fix-bus-errors-with-small-memory-files-Closes-58.patch
Patch0002: 0002-Fix-bus-errors-with-small-memory-files-Closes-58.patch
Patch0003: 0003-Fix-a-segfault-if-unable-to-find-service-token.patch
Patch0004: 0004-Encode-string-used-when-setting-strings.patch
BuildRequires: autoconf automake cppunit-devel doxygen gcc-c++ gettext gettext-devel
BuildRequires: git help2man libtool libxml2-devel pkgconfig python3-devel strace valgrind
@ -171,6 +173,9 @@ rename %{pot_file}.mo %{lang_dom}.mo $(find %{buildroot}/%{_datadir} -name %{pot
%{_mandir}/man?/smbios-*
%changelog
* Thu Oct 19 2023 liyuanyuan <liyuanyuan@xfusion.com> - 2.4.2-5
- Fix Segmentation Fault in Dell Precision T1700
* Thu Oct 12 2023 liyuanyuan <liyuanyuan@xfusion.com> - 2.4.2-4
- Fix bus errors with small memory files