Skip to content

Commit 77c5f58

Browse files
sipaFuzzbawls
authored andcommitted
Put bounds on the number of CPUID leaves explored
1 parent 2b44d19 commit 77c5f58

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/randomenv.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ void AddAllCPUID(CSHA512& hasher)
196196
// Iterate over all standard leaves
197197
AddCPUID(hasher, 0, 0, ax, bx, cx, dx); // Returns max leaf in ax
198198
uint32_t max = ax;
199-
for (uint32_t leaf = 1; leaf <= max; ++leaf) {
199+
for (uint32_t leaf = 1; leaf <= max && leaf <= 0xFF; ++leaf) {
200200
uint32_t maxsub = 0;
201-
for (uint32_t subleaf = 0;; ++subleaf) {
201+
for (uint32_t subleaf = 0; subleaf <= 0xFF; ++subleaf) {
202202
AddCPUID(hasher, leaf, subleaf, ax, bx, cx, dx);
203203
// Iterate subleafs for leaf values 4, 7, 11, 13
204204
if (leaf == 4) {
@@ -219,7 +219,7 @@ void AddAllCPUID(CSHA512& hasher)
219219
// Iterate over all extended leaves
220220
AddCPUID(hasher, 0x80000000, 0, ax, bx, cx, dx); // Returns max extended leaf in ax
221221
uint32_t ext_max = ax;
222-
for (uint32_t leaf = 0x80000001; leaf <= ext_max; ++leaf) {
222+
for (uint32_t leaf = 0x80000001; leaf <= ext_max && leaf <= 0x800000FF; ++leaf) {
223223
AddCPUID(hasher, leaf, 0, ax, bx, cx, dx);
224224
}
225225
}

0 commit comments

Comments
 (0)