X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/2be2fb3ed37af204267e90be65e60250991cb6e1..17b5b32f75d4d00e00ff2664ca905c797f455bb1:/generator.c diff --git a/generator.c b/generator.c index 2ffd03f5..5d051580 100644 --- 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; - 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) { @@ -593,6 +596,8 @@ prepare_to_open: notify_others: write_int(f_out, i); + if (protocol_version >= 29 && inplace && !read_batch) + write_byte(f_out, fnamecmp_type); if (f_out_name >= 0) write_byte(f_out_name, fnamecmp_type);