From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH] fireinfo: Fix SEGV in detect_hypervisor()
Date: Thu, 13 Jul 2023 14:05:38 +0000 [thread overview]
Message-ID: <20230713140538.987905-1-michael.tremer@ipfire.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 2787 bytes --]
Fixes: #13155 - _fireinfo.detect_hypervisor() rises Segmentation fault
Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
lfs/fireinfo | 1 +
...-one-error-when-detecting-hypervisor.patch | 38 +++++++++++++++++++
2 files changed, 39 insertions(+)
create mode 100644 src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch
diff --git a/lfs/fireinfo b/lfs/fireinfo
index 8b38885d6..629626d1e 100644
--- a/lfs/fireinfo
+++ b/lfs/fireinfo
@@ -75,6 +75,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/fireinfo-2.2.0-python-3.8.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/fireinfo-system-blacklist-jetways-product-uuid.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/fireinfo-system-ignore-when-the-serial-number-is-ssn.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch
cd $(DIR_APP) && [ -x "configure" ] || sh ./autogen.sh
cd $(DIR_APP) && ./configure --prefix=/usr
diff --git a/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch b/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch
new file mode 100644
index 000000000..0799ecce5
--- /dev/null
+++ b/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch
@@ -0,0 +1,38 @@
+From e3e68b9baa9723916b1999394432e9ad260cfaa2 Mon Sep 17 00:00:00 2001
+From: Michael Tremer <michael.tremer(a)ipfire.org>
+Date: Sat, 1 Jul 2023 09:08:48 +0000
+Subject: [PATCH] virt: Fix off-by-one error when detecting hypervisor
+
+Reported-by: Mauro Condarelli <mc5686(a)mclink.it>
+Fixes: #13155 - _fireinfo.detect_hypervisor() rises Segmentation fault
+Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
+---
+ src/_fireinfo/fireinfo.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/_fireinfo/fireinfo.c b/src/_fireinfo/fireinfo.c
+index 1d3f424..18edf34 100644
+--- a/src/_fireinfo/fireinfo.c
++++ b/src/_fireinfo/fireinfo.c
+@@ -32,8 +32,8 @@ enum hypervisors {
+ HYPER_KVM,
+ HYPER_MSHV,
+ HYPER_VMWARE,
++ // Must always be last
+ HYPER_OTHER,
+- HYPER_LAST /* for loop - must be last*/
+ };
+
+ const char *hypervisor_ids[] = {
+@@ -157,7 +157,7 @@ int detect_hypervisor(int *hypervisor) {
+ *hypervisor = HYPER_OTHER;
+
+ if (*sig.text) {
+- for (int id = HYPER_NONE + 1; id < HYPER_LAST; id++) {
++ for (int id = HYPER_NONE + 1; id < HYPER_OTHER; id++) {
+ if (strcmp(hypervisor_ids[id], sig.text) == 0) {
+ *hypervisor = id;
+ break;
+--
+2.39.2
+
--
2.39.2
next reply other threads:[~2023-07-13 14:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 14:05 Michael Tremer [this message]
2023-07-13 14:24 ` Peter Müller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230713140538.987905-1-michael.tremer@ipfire.org \
--to=michael.tremer@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox