- if (always_checksum) {
- write_buf(f,file->sum,csum_length);
- }
-
- last_mode = file->mode;
- last_rdev = file->rdev;
- last_uid = file->uid;
- last_gid = file->gid;
- last_time = file->modtime;
-
- strncpy(lastname,fname,MAXPATHLEN-1);
- lastname[MAXPATHLEN-1] = 0;
-}
-
-
-
-void receive_file_entry(struct file_struct **fptr,
- unsigned char flags,int f)
-{
- static time_t last_time;
- static mode_t last_mode;
- static dev_t last_rdev;
- static uid_t last_uid;
- static gid_t last_gid;
- static char lastname[MAXPATHLEN];
- char thisname[MAXPATHLEN];
- int l1=0,l2=0;
- char *p;
- struct file_struct *file;
-
- if (flags & SAME_NAME)
- l1 = read_byte(f);
-
- if (flags & LONG_NAME)
- l2 = read_int(f);
- else
- l2 = read_byte(f);
-
- file = (struct file_struct *)malloc(sizeof(*file));
- if (!file) out_of_memory("receive_file_entry");
- bzero((char *)file,sizeof(*file));
- (*fptr) = file;
-
- if (l2 >= MAXPATHLEN-l1) overflow("receive_file_entry");
-
- strncpy(thisname,lastname,l1);
- read_sbuf(f,&thisname[l1],l2);
- thisname[l1+l2] = 0;
-
- strncpy(lastname,thisname,MAXPATHLEN-1);
- lastname[MAXPATHLEN-1] = 0;
-
- clean_fname(thisname);
-
- if ((p = strrchr(thisname,'/'))) {
- static char *lastdir;
- *p = 0;
- if (lastdir && strcmp(thisname, lastdir)==0) {
- file->dirname = lastdir;
- } else {
- file->dirname = strdup(thisname);
- lastdir = file->dirname;
- }
- file->basename = strdup(p+1);
- } else {
- file->dirname = NULL;
- file->basename = strdup(thisname);
- }
-
- if (!file->basename) out_of_memory("receive_file_entry 1");
-
-
- file->length = read_longint(f);
- file->modtime = (flags & SAME_TIME) ? last_time : (time_t)read_int(f);
- file->mode = (flags & SAME_MODE) ? last_mode : (mode_t)read_int(f);
- if (preserve_uid)
- file->uid = (flags & SAME_UID) ? last_uid : (uid_t)read_int(f);
- if (preserve_gid)
- file->gid = (flags & SAME_GID) ? last_gid : (gid_t)read_int(f);
- if (preserve_devices && IS_DEVICE(file->mode))
- file->rdev = (flags & SAME_RDEV) ? last_rdev : (dev_t)read_int(f);
-
- if (preserve_links && S_ISLNK(file->mode)) {
- int l = read_int(f);
- file->link = (char *)malloc(l+1);
- if (!file->link) out_of_memory("receive_file_entry 2");
- read_sbuf(f,file->link,l);
- }
+ if (always_checksum) {
+ if (remote_version < 21) {
+ write_buf(f, file->sum, 2);
+ } else {
+ write_buf(f, file->sum, MD4_SUM_LENGTH);
+ }
+ }
+
+ last_mode = file->mode;
+ last_rdev = file->rdev;
+ last_uid = file->uid;
+ last_gid = file->gid;
+ last_time = file->modtime;
+
+ strlcpy(lastname, fname, MAXPATHLEN);
+ lastname[MAXPATHLEN - 1] = 0;
+
+ io_write_phase = "unknown";
+}
+
+
+
+static void receive_file_entry(struct file_struct **fptr,
+ unsigned flags, int f)
+{
+ static time_t last_time;
+ static mode_t last_mode;
+ static DEV64_T last_rdev;
+ static uid_t last_uid;
+ static gid_t last_gid;
+ static char lastname[MAXPATHLEN];
+ char thisname[MAXPATHLEN];
+ unsigned int l1 = 0, l2 = 0;
+ char *p;
+ struct file_struct *file;
+
+ if (flags & SAME_NAME)
+ l1 = read_byte(f);
+
+ if (flags & LONG_NAME)
+ l2 = read_int(f);
+ else
+ l2 = read_byte(f);
+
+ file = (struct file_struct *) malloc(sizeof(*file));
+ if (!file)
+ out_of_memory("receive_file_entry");
+ memset((char *) file, 0, sizeof(*file));
+ (*fptr) = file;
+
+ if (l2 >= MAXPATHLEN - l1) {
+ rprintf(FERROR,
+ "overflow: flags=0x%x l1=%d l2=%d lastname=%s\n",
+ flags, l1, l2, lastname);
+ overflow("receive_file_entry");
+ }
+
+ strlcpy(thisname, lastname, l1 + 1);
+ read_sbuf(f, &thisname[l1], l2);
+ thisname[l1 + l2] = 0;
+
+ strlcpy(lastname, thisname, MAXPATHLEN);
+ lastname[MAXPATHLEN - 1] = 0;
+
+ clean_fname(thisname);
+
+ if (sanitize_paths) {
+ sanitize_path(thisname, NULL);
+ }
+
+ if ((p = strrchr(thisname, '/'))) {
+ static char *lastdir;
+ *p = 0;
+ if (lastdir && strcmp(thisname, lastdir) == 0) {
+ file->dirname = lastdir;
+ } else {
+ file->dirname = strdup(thisname);
+ lastdir = file->dirname;
+ }
+ file->basename = strdup(p + 1);
+ } else {
+ file->dirname = NULL;
+ file->basename = strdup(thisname);
+ }