From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter =?utf-8?q?M=C3=BCller?= To: development@lists.ipfire.org Subject: Re: [PATCH] fireinfo: Fix SEGV in detect_hypervisor() Date: Thu, 13 Jul 2023 14:24:00 +0000 Message-ID: <741d7cf8-0cfc-1b0d-edaa-4b1b13d21977@ipfire.org> In-Reply-To: <20230713140538.987905-1-michael.tremer@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8472001968918123659==" List-Id: --===============8472001968918123659== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Acked-by: Peter M=C3=BCller > Fixes: #13155 - _fireinfo.detect_hypervisor() rises Segmentation fault > Signed-off-by: Michael Tremer > --- > 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-det= ecting-hypervisor.patch >=20 > 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-sy= stem-blacklist-jetways-product-uuid.patch > cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/fireinfo-sy= stem-ignore-when-the-serial-number-is-ssn.patch > + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo-virt-fix-of= f-by-one-error-when-detecting-hypervisor.patch > =20 > cd $(DIR_APP) && [ -x "configure" ] || sh ./autogen.sh > cd $(DIR_APP) && ./configure --prefix=3D/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-detect= ing-hypervisor.patch > new file mode 100644 > index 000000000..0799ecce5 > --- /dev/null > +++ b/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervi= sor.patch > @@ -0,0 +1,38 @@ > +From e3e68b9baa9723916b1999394432e9ad260cfaa2 Mon Sep 17 00:00:00 2001 > +From: Michael Tremer > +Date: Sat, 1 Jul 2023 09:08:48 +0000 > +Subject: [PATCH] virt: Fix off-by-one error when detecting hypervisor > + > +Reported-by: Mauro Condarelli > +Fixes: #13155 - _fireinfo.detect_hypervisor() rises Segmentation fault > +Signed-off-by: Michael Tremer > +--- > + 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*/ > + }; > +=20 > + const char *hypervisor_ids[] =3D { > +@@ -157,7 +157,7 @@ int detect_hypervisor(int *hypervisor) { > + *hypervisor =3D HYPER_OTHER; > +=20 > + if (*sig.text) { > +- for (int id =3D HYPER_NONE + 1; id < HYPER_LAST; id++) { > ++ for (int id =3D HYPER_NONE + 1; id < HYPER_OTHER; id++) { > + if (strcmp(hypervisor_ids[id], sig.text) =3D=3D 0) { > + *hypervisor =3D id; > + break; > +--=20 > +2.39.2 > + --===============8472001968918123659==--