fixed a bug that made us use only 16 bits of the file checksum when
authorAndrew Tridgell <tridge@samba.org>
Sat, 26 Jun 1999 01:06:38 +0000 (01:06 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 26 Jun 1999 01:06:38 +0000 (01:06 +0000)
comparing checksums for the --checksum (-c) option.

checksum.c
compat.c
flist.c
generator.c
main.c
rsync.h

index edc844f2860d6c2a75f7542d4ef8219a8b4fd2c9..194d899a3f8b596e25567fa9542718fb314ff8b7 100644 (file)
@@ -91,7 +91,7 @@ void file_checksum(char *fname,char *sum,OFF_T size)
        char tmpchunk[CSUM_CHUNK];
        struct mdfour m;
        
-       memset(sum,0,csum_length);
+       memset(sum,0,MD4_SUM_LENGTH);
        
        fd = open(fname,O_RDONLY);
        if (fd == -1) return;
index af72f8b1ec06f3735e4e12b6c3790157956f3280..ee9e05208a7ea89a5971a70d5f22d30c7b012f07 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -23,8 +23,6 @@
 
 extern int am_server;
 
-extern int csum_length;
-
 extern int preserve_links;
 extern int preserve_perms;
 extern int preserve_devices;
diff --git a/flist.c b/flist.c
index c6e0006cb054e8a3401be4c8e41d91bf84e3b28f..b8b4c666669e2b1017f4b923ad456c9377174b74 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -23,8 +23,6 @@
 
 extern struct stats stats;
 
-extern int csum_length;
-
 extern int verbose;
 extern int am_server;
 extern int always_checksum;
@@ -254,7 +252,11 @@ static void send_file_entry(struct file_struct *file,int f,unsigned base_flags)
 #endif
 
        if (always_checksum) {
-               write_buf(f,file->sum,csum_length);
+               if (remote_version < 21) {
+                       write_buf(f,file->sum,2);
+               } else {
+                       write_buf(f,file->sum,MD4_SUM_LENGTH);
+               }
        }       
 
        last_mode = file->mode;
@@ -353,7 +355,11 @@ static void receive_file_entry(struct file_struct **fptr,
        if (always_checksum) {
                file->sum = (char *)malloc(MD4_SUM_LENGTH);
                if (!file->sum) out_of_memory("md4 sum");
-               read_buf(f,file->sum,csum_length);
+               if (remote_version < 21) {
+                       read_buf(f,file->sum,2);
+               } else {
+                       read_buf(f,file->sum,MD4_SUM_LENGTH);
+               }
        }
   
        last_mode = file->mode;
index d77e7b569eb990383977beeb1401ee6b64f798a7..bbc328df498099872af404b7b5d1542a1d9a37fd 100644 (file)
@@ -50,7 +50,11 @@ static int skip_file(char *fname,
        if (always_checksum && S_ISREG(st->st_mode)) {
                char sum[MD4_SUM_LENGTH];
                file_checksum(fname,sum,st->st_size);
-               return (memcmp(sum,file->sum,csum_length) == 0);
+               if (remote_version < 21) {
+                       return (memcmp(sum,file->sum,2) == 0);
+               } else {
+                       return (memcmp(sum,file->sum,MD4_SUM_LENGTH) == 0);
+               }
        }
 
        if (size_only) {
@@ -86,17 +90,19 @@ static int adapt_block_size(struct file_struct *file, int bsize)
 static void send_sums(struct sum_struct *s,int f_out)
 {
        int i;
-
-  /* tell the other guy how many we are going to be doing and how many
-     bytes there are in the last chunk */
+       
+       /* tell the other guy how many we are going to be doing and how many
+          bytes there are in the last chunk */
        write_int(f_out,s?s->count:0);
        write_int(f_out,s?s->n:block_size);
        write_int(f_out,s?s->remainder:0);
-       if (s)
-               for (i=0;i<s->count;i++) {
-                       write_int(f_out,s->sums[i].sum1);
-                       write_buf(f_out,s->sums[i].sum2,csum_length);
-               }
+
+       if (!s) return;
+
+       for (i=0;i<s->count;i++) {
+               write_int(f_out,s->sums[i].sum1);
+               write_buf(f_out,s->sums[i].sum2,csum_length);
+       }
 }
 
 
diff --git a/main.c b/main.c
index db9201afe144f8550552c995ceff5c18a771997c..807409e3486b90371c96f271ee28ada6278c86ef 100644 (file)
--- a/main.c
+++ b/main.c
@@ -23,8 +23,6 @@ time_t starttime = 0;
 
 struct stats stats;
 
-extern int csum_length;
-
 extern int verbose;
 
 static void report(int f)
diff --git a/rsync.h b/rsync.h
index 32d564cb8b2ac1f793a30fb0b1a7fcaa3add40b0..03d38dd9564cd97431c3cdc2252c05be6b4fbc2f 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -47,7 +47,7 @@
 #define SAME_TIME (1<<7)
 
 /* update this if you make incompatible changes */
-#define PROTOCOL_VERSION 20
+#define PROTOCOL_VERSION 21
 #define MIN_PROTOCOL_VERSION 11
 #define MAX_PROTOCOL_VERSION 30