* [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp
@ 2026-06-03 5:50 Kaiyang Wu
2026-06-16 9:01 ` Kaiyang Wu
2026-07-13 14:15 ` Fabian Grünbichler
0 siblings, 2 replies; 8+ messages 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] 8+ messages in thread* Re: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp 2026-06-03 5:50 [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp Kaiyang Wu @ 2026-06-16 9:01 ` Kaiyang Wu 2026-07-13 14:15 ` Fabian Grünbichler 1 sibling, 0 replies; 8+ messages in thread From: Kaiyang Wu @ 2026-06-16 9:01 UTC (permalink / raw) To: pve-devel; +Cc: Kaiyang Wu Gentle ping, can anyone please take a look? Kaiyang On 2026-06-03 13:50, Kaiyang Wu wrote: > 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, ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp 2026-06-03 5:50 [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp Kaiyang Wu 2026-06-16 9:01 ` Kaiyang Wu @ 2026-07-13 14:15 ` Fabian Grünbichler 2026-07-16 2:31 ` Kaiyang Wu 1 sibling, 1 reply; 8+ messages in thread From: Fabian Grünbichler @ 2026-07-13 14:15 UTC (permalink / raw) To: pve-devel, Kaiyang Wu; +Cc: Kaiyang Wu On June 3, 2026 7:50 am, Kaiyang Wu wrote: > 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) { this is wrong - if the vendor is "Authentic" the code would now think it's AMD.. the same would be true if vendor is "AuthenticAMDsomething", because it would only look at the first 12 bytes (granted, that is a pre-existing issue ;)). instead, we'd first need to check for the length, and if it is 12, do the existing checks, if not, either add checks for other vendors, or reject/abort.. > 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) { same applies here, but with `Genuine` (or any other substring prefix of `GenuineIntel`).. > cpu_caps_intel_tdx_t caps_tdx; > if (query_cpu_capabilities_tdx(&caps_tdx) == 0) { > ret = fprintf(file, > -- > 2.52.0 > > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp 2026-07-13 14:15 ` Fabian Grünbichler @ 2026-07-16 2:31 ` Kaiyang Wu 2026-07-29 8:41 ` Kaiyang Wu 0 siblings, 1 reply; 8+ messages in thread From: Kaiyang Wu @ 2026-07-16 2:31 UTC (permalink / raw) To: Fabian Grünbichler, pve-devel; +Cc: Kaiyang Wu Intel TDX and AMD SEV are both x86_64 only extensions [0] [1]. I wonder if the best approach for this issue is to just add a conditional compilation check for x86_64 target architecture. If that works I will switch to compile time architecture check in v2. [0]: https://docs.kernel.org/arch/x86/tdx.html [1]: https://docs.kernel.org/virt/kvm/x86/amd-memory-encryption.html On 2026-07-13 22:15, Fabian Grünbichler wrote: > On June 3, 2026 7:50 am, Kaiyang Wu wrote: >> 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) { > > this is wrong - if the vendor is "Authentic" the code would now think > it's AMD.. the same would be true if vendor is "AuthenticAMDsomething", > because it would only look at the first 12 bytes (granted, that is a > pre-existing issue ;)). > > instead, we'd first need to check for the length, and if it is 12, do > the existing checks, if not, either add checks for other vendors, or > reject/abort.. > >> 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) { > > same applies here, but with `Genuine` (or any other substring prefix of > `GenuineIntel`).. > >> cpu_caps_intel_tdx_t caps_tdx; >> if (query_cpu_capabilities_tdx(&caps_tdx) == 0) { >> ret = fprintf(file, >> -- >> 2.52.0 >> >> >> >> >> > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp 2026-07-16 2:31 ` Kaiyang Wu @ 2026-07-29 8:41 ` Kaiyang Wu 2026-07-29 10:16 ` Fiona Ebner 0 siblings, 1 reply; 8+ messages in thread From: Kaiyang Wu @ 2026-07-29 8:41 UTC (permalink / raw) To: Fabian Grünbichler, pve-devel; +Cc: Kaiyang Wu Gentle ping. Kaiyang On 2026-07-16 10:31, Kaiyang Wu wrote: > Intel TDX and AMD SEV are both x86_64 only extensions [0] [1]. I wonder > if the best approach for this issue is to just add a conditional > compilation check for x86_64 target architecture. > > If that works I will switch to compile time architecture check in v2. > > [0]: https://docs.kernel.org/arch/x86/tdx.html > [1]: https://docs.kernel.org/virt/kvm/x86/amd-memory-encryption.html > > On 2026-07-13 22:15, Fabian Grünbichler wrote: >> On June 3, 2026 7:50 am, Kaiyang Wu wrote: >>> 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) { >> >> this is wrong - if the vendor is "Authentic" the code would now think >> it's AMD.. the same would be true if vendor is "AuthenticAMDsomething", >> because it would only look at the first 12 bytes (granted, that is a >> pre-existing issue ;)). >> >> instead, we'd first need to check for the length, and if it is 12, do >> the existing checks, if not, either add checks for other vendors, or >> reject/abort.. >> >>> 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) { >> >> same applies here, but with `Genuine` (or any other substring prefix of >> `GenuineIntel`).. >> >>> cpu_caps_intel_tdx_t caps_tdx; >>> if (query_cpu_capabilities_tdx(&caps_tdx) == 0) { >>> ret = fprintf(file, >>> -- >>> 2.52.0 >>> >>> >>> >>> >>> >> > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp 2026-07-29 8:41 ` Kaiyang Wu @ 2026-07-29 10:16 ` Fiona Ebner 2026-07-29 11:12 ` Kaiyang Wu 2026-07-29 11:13 ` superseded: " Kaiyang Wu 0 siblings, 2 replies; 8+ messages in thread From: Fiona Ebner @ 2026-07-29 10:16 UTC (permalink / raw) To: Kaiyang Wu, Fabian Grünbichler, pve-devel; +Cc: Kaiyang Wu Am 29.07.26 um 10:41 AM schrieb Kaiyang Wu: > Gentle ping. > > Kaiyang > > On 2026-07-16 10:31, Kaiyang Wu wrote: >> Intel TDX and AMD SEV are both x86_64 only extensions [0] [1]. I >> wonder if the best approach for this issue is to just add a >> conditional compilation check for x86_64 target architecture. >> >> If that works I will switch to compile time architecture check in v2. >> >> [0]: https://docs.kernel.org/arch/x86/tdx.html >> [1]: https://docs.kernel.org/virt/kvm/x86/amd-memory-encryption.html >> Yes, I think the checks for AuthenticAMD and GenuineIntel can be put into conditional compilation for x86_64 right now. There already is a conditional inside query_cpu_capabilities_sev() but that can be dropped afterwards. >> On 2026-07-13 22:15, Fabian Grünbichler wrote: >>> On June 3, 2026 7:50 am, Kaiyang Wu wrote: >>>> 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) { >>> >>> this is wrong - if the vendor is "Authentic" the code would now think >>> it's AMD.. the same would be true if vendor is "AuthenticAMDsomething", >>> because it would only look at the first 12 bytes (granted, that is a >>> pre-existing issue ;)). >>> >>> instead, we'd first need to check for the length, and if it is 12, do >>> the existing checks, if not, either add checks for other vendors, or >>> reject/abort.. >>> >>>> 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) { >>> >>> same applies here, but with `Genuine` (or any other substring prefix of >>> `GenuineIntel`).. >>> >>>> cpu_caps_intel_tdx_t caps_tdx; >>>> if (query_cpu_capabilities_tdx(&caps_tdx) == 0) { >>>> ret = fprintf(file, >>>> -- >>>> 2.52.0 >>>> >>>> >>>> >>>> >>>> >>> >> > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp 2026-07-29 10:16 ` Fiona Ebner @ 2026-07-29 11:12 ` Kaiyang Wu 2026-07-29 11:13 ` superseded: " Kaiyang Wu 1 sibling, 0 replies; 8+ messages in thread From: Kaiyang Wu @ 2026-07-29 11:12 UTC (permalink / raw) To: Fiona Ebner, Fabian Grünbichler, pve-devel; +Cc: Kaiyang Wu Thanks, v2 addressed this using conditional compilation. On 2026-07-29 18:16, Fiona Ebner wrote: > Am 29.07.26 um 10:41 AM schrieb Kaiyang Wu: >> Gentle ping. >> >> Kaiyang >> >> On 2026-07-16 10:31, Kaiyang Wu wrote: >>> Intel TDX and AMD SEV are both x86_64 only extensions [0] [1]. I >>> wonder if the best approach for this issue is to just add a >>> conditional compilation check for x86_64 target architecture. >>> >>> If that works I will switch to compile time architecture check in v2. >>> >>> [0]: https://docs.kernel.org/arch/x86/tdx.html >>> [1]: https://docs.kernel.org/virt/kvm/x86/amd-memory-encryption.html >>> > > Yes, I think the checks for AuthenticAMD and GenuineIntel can be put > into conditional compilation for x86_64 right now. There already is a > conditional inside query_cpu_capabilities_sev() but that can be dropped > afterwards. > >>> On 2026-07-13 22:15, Fabian Grünbichler wrote: >>>> On June 3, 2026 7:50 am, Kaiyang Wu wrote: >>>>> 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) { >>>> >>>> this is wrong - if the vendor is "Authentic" the code would now think >>>> it's AMD.. the same would be true if vendor is "AuthenticAMDsomething", >>>> because it would only look at the first 12 bytes (granted, that is a >>>> pre-existing issue ;)). >>>> >>>> instead, we'd first need to check for the length, and if it is 12, do >>>> the existing checks, if not, either add checks for other vendors, or >>>> reject/abort.. >>>> >>>>> 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) { >>>> >>>> same applies here, but with `Genuine` (or any other substring prefix of >>>> `GenuineIntel`).. >>>> >>>>> cpu_caps_intel_tdx_t caps_tdx; >>>>> if (query_cpu_capabilities_tdx(&caps_tdx) == 0) { >>>>> ret = fprintf(file, >>>>> -- >>>>> 2.52.0 >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>> >> >> >> >> > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* superseded: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp 2026-07-29 10:16 ` Fiona Ebner 2026-07-29 11:12 ` Kaiyang Wu @ 2026-07-29 11:13 ` Kaiyang Wu 1 sibling, 0 replies; 8+ messages in thread From: Kaiyang Wu @ 2026-07-29 11:13 UTC (permalink / raw) To: Fiona Ebner, Fabian Grünbichler, pve-devel; +Cc: Kaiyang Wu https://lore.proxmox.com/pve-devel/20260729111024.58285-2-wukaiyang@loongfans.cn/ On 2026-07-29 18:16, Fiona Ebner wrote: > Am 29.07.26 um 10:41 AM schrieb Kaiyang Wu: >> Gentle ping. >> >> Kaiyang >> >> On 2026-07-16 10:31, Kaiyang Wu wrote: >>> Intel TDX and AMD SEV are both x86_64 only extensions [0] [1]. I >>> wonder if the best approach for this issue is to just add a >>> conditional compilation check for x86_64 target architecture. >>> >>> If that works I will switch to compile time architecture check in v2. >>> >>> [0]: https://docs.kernel.org/arch/x86/tdx.html >>> [1]: https://docs.kernel.org/virt/kvm/x86/amd-memory-encryption.html >>> > > Yes, I think the checks for AuthenticAMD and GenuineIntel can be put > into conditional compilation for x86_64 right now. There already is a > conditional inside query_cpu_capabilities_sev() but that can be dropped > afterwards. > >>> On 2026-07-13 22:15, Fabian Grünbichler wrote: >>>> On June 3, 2026 7:50 am, Kaiyang Wu wrote: >>>>> 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) { >>>> >>>> this is wrong - if the vendor is "Authentic" the code would now think >>>> it's AMD.. the same would be true if vendor is "AuthenticAMDsomething", >>>> because it would only look at the first 12 bytes (granted, that is a >>>> pre-existing issue ;)). >>>> >>>> instead, we'd first need to check for the length, and if it is 12, do >>>> the existing checks, if not, either add checks for other vendors, or >>>> reject/abort.. >>>> >>>>> 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) { >>>> >>>> same applies here, but with `Genuine` (or any other substring prefix of >>>> `GenuineIntel`).. >>>> >>>>> cpu_caps_intel_tdx_t caps_tdx; >>>>> if (query_cpu_capabilities_tdx(&caps_tdx) == 0) { >>>>> ret = fprintf(file, >>>>> -- >>>>> 2.52.0 >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>> >> >> >> >> > > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-07-29 11:14 UTC | newest] Thread overview: 8+ messages (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 2026-06-16 9:01 ` Kaiyang Wu 2026-07-13 14:15 ` Fabian Grünbichler 2026-07-16 2:31 ` Kaiyang Wu 2026-07-29 8:41 ` Kaiyang Wu 2026-07-29 10:16 ` Fiona Ebner 2026-07-29 11:12 ` Kaiyang Wu 2026-07-29 11:13 ` superseded: " Kaiyang Wu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox