From e95c27cb952b47058725eb34623c0c7880fc0b03 Mon Sep 17 00:00:00 2001 From: liyuan Date: Thu, 19 Oct 2023 19:41:24 +0800 Subject: [PATCH] backport Fix Segmentation Fault in Dell Precision T1700 --- ...ault-if-unable-to-find-service-token.patch | 25 +++++++++++ ...ode-string-used-when-setting-strings.patch | 43 +++++++++++++++++++ libsmbios.spec | 9 +++- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 0003-Fix-a-segfault-if-unable-to-find-service-token.patch create mode 100644 0004-Encode-string-used-when-setting-strings.patch diff --git a/0003-Fix-a-segfault-if-unable-to-find-service-token.patch b/0003-Fix-a-segfault-if-unable-to-find-service-token.patch new file mode 100644 index 0000000..65d2728 --- /dev/null +++ b/0003-Fix-a-segfault-if-unable-to-find-service-token.patch @@ -0,0 +1,25 @@ +From d849a11447ace88fe505460178dc0b74f580c0d7 Mon Sep 17 00:00:00 2001 +From: Mario Limonciello +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 + diff --git a/0004-Encode-string-used-when-setting-strings.patch b/0004-Encode-string-used-when-setting-strings.patch new file mode 100644 index 0000000..d28d5a3 --- /dev/null +++ b/0004-Encode-string-used-when-setting-strings.patch @@ -0,0 +1,43 @@ +From 0cd2e55565cd1c1b8f2bc14fafb690083e278923 Mon Sep 17 00:00:00 2001 +From: Mario Limonciello +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 + diff --git a/libsmbios.spec b/libsmbios.spec index 500b8a1..f271354 100644 --- a/libsmbios.spec +++ b/libsmbios.spec @@ -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 - 2.4.2-5 +- Fix Segmentation Fault in Dell Precision T1700 + * Thu Oct 12 2023 liyuanyuan - 2.4.2-4 - Fix bus errors with small memory files -- Gitee