Blame SOURCES/0020-helper-Fix-KVM-signature.patch

c18f13
From e0443f1fc78f2a79c073dbdf4133bec41c4c0591 Mon Sep 17 00:00:00 2001
c18f13
From: "Richard W.M. Jones" <rjones@redhat.com>
c18f13
Date: Fri, 4 Oct 2019 18:30:01 +0100
a41150
Subject: [PATCH 20/25] helper: Fix KVM signature.
c18f13
c18f13
Thanks: Paolo Bonzini.
c18f13
---
c18f13
 virt-what-cpuid-helper.c | 9 +++++----
c18f13
 1 file changed, 5 insertions(+), 4 deletions(-)
c18f13
c18f13
diff --git a/virt-what-cpuid-helper.c b/virt-what-cpuid-helper.c
c18f13
index 0cd4a6f..9c6cdb2 100644
c18f13
--- a/virt-what-cpuid-helper.c
c18f13
+++ b/virt-what-cpuid-helper.c
c18f13
@@ -28,15 +28,16 @@
c18f13
 #if defined(__i386__) || defined(__x86_64__)
c18f13
 
c18f13
 /* Known x86 hypervisor signatures.  Note that if you add a new test
c18f13
- * to virt-what.in you may need to update this list.  The signature is
c18f13
- * always 12 bytes except in the case of KVM.
c18f13
+ * to virt-what.in you may need to update this list.  Note the
c18f13
+ * signature is always 12 bytes long, plus we add \0 to the end to
c18f13
+ * make it 13 bytes.
c18f13
  */
c18f13
 static int
c18f13
-known_signature (char *sig)
c18f13
+known_signature (const char *sig)
c18f13
 {
c18f13
   return
c18f13
     strcmp (sig, "bhyve bhyve ") == 0 ||
c18f13
-    strcmp (sig, "KVMKVMKVM") == 0 ||
c18f13
+    memcmp (sig, "KVMKVMKVM\0\0\0", 12) == 0 ||
c18f13
     strcmp (sig, "LKVMLKVMLKVM") == 0 ||
c18f13
     strcmp (sig, "Microsoft Hv") == 0 ||
c18f13
     strcmp (sig, "OpenBSDVMM58") == 0 ||
c18f13
-- 
a41150
2.18.4
c18f13