+@@ -502,7 +503,7 @@ static struct file_struct *receive_file_
+ char thisname[MAXPATHLEN];
+ unsigned int l1 = 0, l2 = 0;
+ int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
+-#ifdef SUPPORT_ACLS
++#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
+ int xtra_len;
+ #endif
+ OFF_T file_length;
+@@ -614,10 +615,16 @@ static struct file_struct *receive_file_
+ xtra_len = (S_ISDIR(mode) ? 2 : 1) * 4;
+ else
+ xtra_len = 0;
++#elif defined SUPPORT_XATTRS
++ xtra_len = 0;
++#endif
++#ifdef SUPPORT_XATTRS
++ if (preserve_xattrs)
++ xtra_len += 4;
+ #endif
+
+ alloc_len = file_struct_len + dirname_len + basename_len
+-#ifdef SUPPORT_ACLS
++#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
+ + xtra_len
+ #endif
+ + linkname_len + sum_len;
+@@ -626,7 +633,7 @@ static struct file_struct *receive_file_
+ file = (struct file_struct *)bp;
+ memset(bp, 0, file_struct_len);
+ bp += file_struct_len;
+-#ifdef SUPPORT_ACLS
++#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
+ bp += xtra_len;
+ #endif
+
+@@ -727,6 +734,10 @@ static struct file_struct *receive_file_
+ if (preserve_acls)
+ receive_acl(file, f);
+ #endif
++#ifdef SUPPORT_XATTRS
++ if (preserve_xattrs)
++ receive_xattr(file, f );
++#endif
+
+ return file;
+ }
+@@ -997,6 +1008,13 @@ static struct file_struct *send_file_nam
+ return NULL;
+ }