]> git.saurik.com Git - ldid.git/commitdiff
Fix range check error re-hashing degenerate files. master
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 23 Aug 2024 18:34:03 +0000 (11:34 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 23 Aug 2024 18:34:03 +0000 (11:34 -0700)
ldid.cpp

index b46335b457663fea3ed87963011ddd83b72b0a01..0769e7e32e327a9d9f3aedc5b713d7f2b5d85a93 100644 (file)
--- a/ldid.cpp
+++ b/ldid.cpp
@@ -3630,11 +3630,11 @@ int main(int argc, char *argv[]) {
                         uint8_t *hashes = reinterpret_cast<uint8_t *>(blob + begin + Swap(directory->hashOffset));
                         uint32_t pages = Swap(directory->nCodeSlots);
 
                         uint8_t *hashes = reinterpret_cast<uint8_t *>(blob + begin + Swap(directory->hashOffset));
                         uint32_t pages = Swap(directory->nCodeSlots);
 
-                        if (pages != 1)
+                        if (pages != 0) {
                             for (size_t i = 0; i != pages - 1; ++i)
                                 algorithm(hashes + i * algorithm.size_, top + PageSize_ * i, PageSize_);
                             for (size_t i = 0; i != pages - 1; ++i)
                                 algorithm(hashes + i * algorithm.size_, top + PageSize_ * i, PageSize_);
-                        if (pages != 0)
                             algorithm(hashes + (pages - 1) * algorithm.size_, top + PageSize_ * (pages - 1), ((data - 1) % PageSize_) + 1);
                             algorithm(hashes + (pages - 1) * algorithm.size_, top + PageSize_ * (pages - 1), ((data - 1) % PageSize_) + 1);
+                        }
                     }
                 }
             }
                     }
                 }
             }