Skip to content

Commit

Permalink
Prevent intel_fn11 array overruns
Browse files Browse the repository at this point in the history
First check whether we are past the array, only
then read and check its values.
  • Loading branch information
zacikpa committed May 23, 2024
1 parent 6ccf2ae commit 0f42704
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libcpuid/recog_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0f42704

Please sign in to comment.