--- old/compat.c
+++ new/compat.c
-@@ -115,13 +115,6 @@ void setup_protocol(int f_out,int f_in)
+@@ -147,13 +147,6 @@ void setup_protocol(int f_out,int f_in)
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
#define RSYNC_XAL_INITIAL 5
#define RSYNC_XAL_LIST_INITIAL 100
-@@ -222,7 +224,7 @@ static int rsync_xal_get(const char *fna
+@@ -231,7 +233,7 @@ static int rsync_xal_get(const char *fna
if (!(ptr = get_xattr_data(fname, name, &datum_len, 0)))
return -1;
/* For large datums, we store a flag and a checksum. */
name_offset = 1 + MAX_DIGEST_LEN;
sum_init(checksum_seed);
-@@ -278,7 +280,7 @@ static int find_matching_xattr(item_list
+@@ -295,7 +297,7 @@ static int find_matching_xattr(item_list
|| rxas1[j].datum_len != rxas2[j].datum_len
|| strcmp(rxas1[j].name, rxas2[j].name))
break;
if (memcmp(rxas1[j].datum + 1,
rxas2[j].datum + 1,
MAX_DIGEST_LEN) != 0)
-@@ -315,34 +317,43 @@ int send_xattr(statx *sxp, int f)
+@@ -332,34 +334,43 @@ int send_xattr(statx *sxp, int f)
{
int ndx = find_matching_xattr(sxp->xattr);
write_buf(f, rxa->datum + 1, MAX_DIGEST_LEN);
else
write_buf(f, rxa->datum, rxa->datum_len);
-@@ -392,7 +403,7 @@ int xattr_diff(struct file_struct *file,
+@@ -409,7 +420,7 @@ int xattr_diff(struct file_struct *file,
cmp = rec_cnt ? strcmp(snd_rxa->name, rec_rxa->name) : -1;
if (cmp > 0)
same = 0;
same = cmp == 0 && snd_rxa->datum_len == rec_rxa->datum_len
&& memcmp(snd_rxa->datum + 1, rec_rxa->datum + 1,
MAX_DIGEST_LEN) == 0;
-@@ -435,6 +446,9 @@ void send_xattr_request(const char *fnam
+@@ -452,6 +463,9 @@ void send_xattr_request(const char *fnam
int j, cnt, prior_req = -1;
rsync_xa *rxa;
lst += F_XATTR(file);
cnt = lst->count;
for (rxa = lst->items, j = 0; j < cnt; rxa++, j++) {
-@@ -506,6 +520,9 @@ void recv_xattr_request(struct file_stru
+@@ -523,6 +537,9 @@ void recv_xattr_request(struct file_stru
rsync_xa *rxa;
int rel_pos, cnt;
if (F_XATTR(file) < 0) {
rprintf(FERROR, "recv_xattr_request: internal data error!\n");
exit_cleanup(RERR_STREAMIO);
-@@ -552,7 +569,22 @@ void receive_xattr(struct file_struct *f
+@@ -569,7 +586,22 @@ void receive_xattr(struct file_struct *f
{
static item_list temp_xattr = EMPTY_ITEM_LIST;
int count;
if (ndx < 0 || (size_t)ndx > rsync_xal_l.count) {
rprintf(FERROR, "receive_xattr: xa index %d out of"
-@@ -565,7 +597,7 @@ void receive_xattr(struct file_struct *f
+@@ -582,7 +614,7 @@ void receive_xattr(struct file_struct *f
return;
}
(void)EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count);
temp_xattr.count = 0;
}
-@@ -573,9 +605,10 @@ void receive_xattr(struct file_struct *f
+@@ -590,9 +622,10 @@ void receive_xattr(struct file_struct *f
while (count--) {
char *ptr, *name;
rsync_xa *rxa;
+ size_t datum_len = read_varint30(f);
+ size_t dget_len = datum_len > MAX_FULL_DATUM && protocol_version >= 30
+ ? 1 + MAX_DIGEST_LEN : datum_len;
- #ifdef HAVE_LINUX_XATTRS
- size_t extra_len = 0;
- #else
+ size_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0;
+ if (dget_len + extra_len < dget_len)
+ out_of_memory("receive_xattr"); /* overflow */