Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
54281fe
)
Make sure that we don't compute a block size larger than MAX_BLOCK_SIZE.
author
Wayne Davison
<wayned@samba.org>
Mon, 17 Jan 2005 22:51:21 +0000
(22:51 +0000)
committer
Wayne Davison
<wayned@samba.org>
Mon, 17 Jan 2005 22:51:21 +0000
(22:51 +0000)
generator.c
patch
|
blob
|
blame
|
history
diff --git
a/generator.c
b/generator.c
index
2ffd03f
..
1c08e5e
100644
(file)
--- a/
generator.c
+++ b/
generator.c
@@
-146,17
+146,20
@@
static void sum_sizes_sqroot(struct sum_struct *sum, uint64 len)
else {
int32 c;
uint64 l;
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;
+ if (len < (uint64)blength * blength)
+ blength &= ~c;
+ c >>= 1;
+ } while (c >= 8); /* round to multiple of 8 */
+ blength = MAX(blength, BLOCK_SIZE);
}
}
- blength = 0;
- do {
- blength |= c;
- if (len < (uint64)blength * blength)
- blength &= ~c;
- c >>= 1;
- } while (c >= 8); /* round to multiple of 8 */
- blength = MAX(blength, BLOCK_SIZE);
}
if (protocol_version < 27) {
}
if (protocol_version < 27) {