Commit 91ff4e41 authored by Oliver Steffen's avatar Oliver Steffen

common: fix uint overflow in getStripeTargetIndex()

expressed formula differently:

   (pos % stripeSetSize) / chunkSize
 = (pos % (numTargets * chunkSize)) / chunkSize
 = (pos / chunkSize) % numTargets

 (pos / chunkSize): number of chunks from beginning of file

removes the previously overflowing stripeSetSize variable.

(cherry picked from da4e5efa2b931a10b0d460458316c41f4a639563)
parent 3deca9fa
......@@ -139,10 +139,7 @@ class StripePattern
*/
size_t getStripeTargetIndex(int64_t pos) const
{
const unsigned chunkSize = getChunkSize();
const unsigned stripeSetSize = getNumStripeTargetIDs() * chunkSize;
return (pos % stripeSetSize) / chunkSize;
return (pos / getChunkSize()) % getNumStripeTargetIDs();
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment