Skip to content

Commit f93fc61

Browse files
committed
Put bounds on the number of CPUID leaves explored
1 parent ba2c5fe commit f93fc61

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/randomenv.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ void AddAllCPUID(CSHA512& hasher)
197197
// Iterate over all standard leaves
198198
AddCPUID(hasher, 0, 0, ax, bx, cx, dx); // Returns max leaf in ax
199199
uint32_t max = ax;
200-
for (uint32_t leaf = 1; leaf <= max; ++leaf) {
200+
for (uint32_t leaf = 1; leaf <= max && leaf <= 0xFF; ++leaf) {
201201
uint32_t maxsub = 0;
202-
for (uint32_t subleaf = 0;; ++subleaf) {
202+
for (uint32_t subleaf = 0; subleaf <= 0xFF; ++subleaf) {
203203
AddCPUID(hasher, leaf, subleaf, ax, bx, cx, dx);
204204
// Iterate subleafs for leaf values 4, 7, 11, 13
205205
if (leaf == 4) {
@@ -220,7 +220,7 @@ void AddAllCPUID(CSHA512& hasher)
220220
// Iterate over all extended leaves
221221
AddCPUID(hasher, 0x80000000, 0, ax, bx, cx, dx); // Returns max extended leaf in ax
222222
uint32_t ext_max = ax;
223-
for (uint32_t leaf = 0x80000001; leaf <= ext_max; ++leaf) {
223+
for (uint32_t leaf = 0x80000001; leaf <= ext_max && leaf <= 0x800000FF; ++leaf) {
224224
AddCPUID(hasher, leaf, 0, ax, bx, cx, dx);
225225
}
226226
}

0 commit comments

Comments
 (0)