all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp
@ 2026-06-03  5:50 Kaiyang Wu
  0 siblings, 0 replies; only message in thread
From: Kaiyang Wu @ 2026-06-03  5:50 UTC (permalink / raw)
  To: pve-devel; +Cc: Kaiyang Wu

Fix build error on unknown vendors ('fallback'):

	error: ‘strncmp’ of strings of length 7 and 12 and bound of 12 evaluates to nonzero [-Werror=string-compare]

Signed-off-by: Kaiyang Wu <wukaiyang@loongfans.cn>
---
 src/query-machine-capabilities/query-machine-capabilities.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/query-machine-capabilities/query-machine-capabilities.c b/src/query-machine-capabilities/query-machine-capabilities.c
index abb47acd..25d06db7 100644
--- a/src/query-machine-capabilities/query-machine-capabilities.c
+++ b/src/query-machine-capabilities/query-machine-capabilities.c
@@ -204,7 +204,7 @@ int main() {
         eprintf("Error writing to file '" OUTPUT_PATH "': %s\n", strerror(errno));
     }
 
-    if (strncmp(vendor, "AuthenticAMD", 12) == 0) {
+    if (strncmp(vendor, "AuthenticAMD", strnlen(vendor, 12)) == 0) {
         cpu_caps_amd_sev_t caps_sev;
         query_cpu_capabilities_sev(&caps_sev);
 
@@ -222,7 +222,7 @@ int main() {
             caps_sev.sev_es_support ? "true" : "false",
             caps_sev.sev_snp_support ? "true" : "false"
         );
-    } else if (strncmp(vendor, "GenuineIntel", 12) == 0) {
+    } else if (strncmp(vendor, "GenuineIntel", strnlen(vendor, 12)) == 0) {
         cpu_caps_intel_tdx_t caps_tdx;
         if (query_cpu_capabilities_tdx(&caps_tdx) == 0) {
             ret = fprintf(file,
-- 
2.52.0




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-03  5:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03  5:50 [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp Kaiyang Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal