Commit eae7165c authored by Wayne Davison's avatar Wayne Davison

Make sure that we don't compute a block size larger than MAX_BLOCK_SIZE.

parent 54281fe7
......@@ -146,9 +146,11 @@ static void sum_sizes_sqroot(struct sum_struct *sum, uint64 len)
else {
int32 c;
uint64 l;
for (c = 1, l = len; l >>= 2; c <<= 1) {
assert(c > 0);
}
int cnt;
for (c = 1, l = len, cnt = 0; l >>= 2; c <<= 1, cnt++) {}
if (cnt >= 31 || c >= MAX_BLOCK_SIZE)
blength = MAX_BLOCK_SIZE;
else {
blength = 0;
do {
blength |= c;
......@@ -158,6 +160,7 @@ static void sum_sizes_sqroot(struct sum_struct *sum, uint64 len)
} while (c >= 8); /* round to multiple of 8 */
blength = MAX(blength, BLOCK_SIZE);
}
}
if (protocol_version < 27) {
s2length = csum_length;
......
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