From 381b3352c64c06fac84cfae44063e225821dbb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= Date: Thu, 23 May 2024 10:19:14 +0200 Subject: [PATCH] Prevent intel_fn11 array overruns First check whether we are past the array, only then read and check its values. --- libcpuid/recog_intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpuid/recog_intel.c b/libcpuid/recog_intel.c index e385a7c..a091843 100644 --- a/libcpuid/recog_intel.c +++ b/libcpuid/recog_intel.c @@ -721,7 +721,7 @@ static int decode_intel_extended_topology(struct cpu_raw_data_t* raw, struct cpu { int i, level_type, num_smt = -1, num_core = -1; - for (i = 0; (raw->intel_fn11[i][EAX] != 0x0) && (raw->intel_fn11[i][EBX] != 0x0) && (i < MAX_INTELFN11_LEVEL); i++) { + for (i = 0; (i < MAX_INTELFN11_LEVEL) && (raw->intel_fn11[i][EAX] != 0x0) && (raw->intel_fn11[i][EBX] != 0x0); i++) { level_type = EXTRACTS_BITS(raw->intel_fn11[i][ECX], 15, 8); switch (level_type) { case 0x01: