From aa58a0999d4e2c41d438645bc09eead5de31f869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 21 Apr 2024 17:57:32 +0800 Subject: [PATCH] CPU (Windows): try detecting invalid data in SMBIOS Work around #800 --- src/detection/cpu/cpu_windows.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 855ae7d29..2a8b69bfb 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -64,13 +64,12 @@ static const char* detectMaxSpeedBySmbios(FFCPUResult* cpu) return "No active CPU is found in SMBIOS data"; } - if (data->MaxSpeed > 0 && data->MaxSpeed < 30000) // VMware reports weird values - { - double speed = data->MaxSpeed / 1000.0; - if (cpu->frequencyBase < speed) - cpu->frequencyMax = speed; - } + double speed = data->MaxSpeed / 1000.0; + // Sometimes SMBIOS reports invalid value. We assume that max speed is small than 2x of base + if (speed < cpu->frequencyBase || speed > cpu->frequencyBase * 2) + return "Possible invalid CPU max speed in SMBIOS data. See #800"; + cpu->frequencyMax = speed; return NULL; }