fixed a bug in handling the -c option and non-regular files. It hadn't
authorAndrew Tridgell <tridge@samba.org>
Thu, 9 Apr 1998 00:38:40 +0000 (00:38 +0000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 9 Apr 1998 00:38:40 +0000 (00:38 +0000)
turned up before because Linux had a bug in the handling of NULL
pointers to read()/write() on pipes, so I never noticed the bug in my
testing.

I've also sent a patch to Linus.

flist.c

diff --git a/flist.c b/flist.c
index 3e3b3a6..63b8663 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -209,7 +209,7 @@ void send_file_entry(struct file_struct *file,int f)
 #endif
 
   if (always_checksum) {
-    write_buf(f,file->sum,csum_length);
+         write_buf(f,file->sum,csum_length);
   }       
 
   last_mode = file->mode;
@@ -426,10 +426,17 @@ static struct file_struct *make_file(char *fname)
        }
 #endif
 
-       if (always_checksum && S_ISREG(st.st_mode)) {
+       if (always_checksum) {
                file->sum = (char *)malloc(MD4_SUM_LENGTH);
                if (!file->sum) out_of_memory("md4 sum");
-               file_checksum(fname,file->sum,st.st_size);
+               /* drat. we have to provide a null checksum for non-regular
+                  files in order to be compatible with earlier versions
+                  of rsync */
+               if (S_ISREG(st.st_mode)) {
+                       file_checksum(fname,file->sum,st.st_size);
+               } else {
+                       memset(file->sum, 0, MD4_SUM_LENGTH);
+               }
        }       
 
        if (flist_dir) {