libsmbios/0003-Fix-a-segfault-if-unable-to-find-service-token.patch

26 lines
1.0 KiB
Diff

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