X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/67347196b13941fdf455517855481875ccf21152..bb4e4d889f51065dcef6f34d8ba4a80c051149a1:/generator.c diff --git a/generator.c b/generator.c index 1fcdb4c2..724cebec 100644 --- a/generator.c +++ b/generator.c @@ -763,11 +763,12 @@ static void sum_sizes_sqroot(struct sum_struct *sum, int64 len) else if (len <= BLOCK_SIZE * BLOCK_SIZE) blength = BLOCK_SIZE; else { + int32 max_blength = protocol_version < 30 ? OLD_MAX_BLOCK_SIZE : MAX_BLOCK_SIZE; int32 c; 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; + if (c < 0 || c >= max_blength) + blength = max_blength; else { blength = 0; do { @@ -1952,9 +1953,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, if (read_batch) goto cleanup; - if (statret != 0 || whole_file || sx.st.st_size <= 0) + if (statret != 0 || whole_file) write_sum_head(f_out, NULL); - else { + else if (sx.st.st_size <= 0) { + write_sum_head(f_out, NULL); + close(fd); + } else { if (generate_and_send_sums(fd, sx.st.st_size, f_out, f_copy) < 0) { rprintf(FWARNING, "WARNING: file is too large for checksum sending: %s\n",