From: Wayne Davison Date: Sun, 26 Jun 2016 18:46:18 +0000 (-0700) Subject: Fix "could not find xattr #1" errors. X-Git-Tag: v3.1.3pre1~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a720d81d0a81cf1b5f2616e93e26ebe4547c1aed;p=thirdparty%2Frsync.git Fix "could not find xattr #1" errors. The abbreviated-xattr code can get requests that are not in the same order as the xattr list, so we need to support wrap-around scanning of the available xattrs. Fixes bug 6590. --- diff --git a/xattrs.c b/xattrs.c index 6a77a0bc..0658afbb 100644 --- a/xattrs.c +++ b/xattrs.c @@ -611,10 +611,32 @@ int recv_xattr_request(struct file_struct *file, int f_in) num = 0; while ((rel_pos = read_varint(f_in)) != 0) { num += rel_pos; - /* Note that the sender-related num values may not be in order on the receiver! */ - while (cnt && (am_sender ? rxa->num < num : rxa->num != num)) { - rxa++; - cnt--; + if (am_sender) { + /* The sender-related num values are only in order on the sender. + * We use that order here to scan foward or backward as needed. */ + if (rel_pos < 0) { + while (cnt < (int)lst->count && rxa->num > num) { + rxa--; + cnt++; + } + } else { + while (cnt > 1 && rxa->num < num) { + rxa++; + cnt--; + } + } + } else { + int j; + /* The receiving side has no known num order, so we just scan + * forward (w/wrap) and hope that the next value is near by. */ + for (j = lst->count; j > 1 && rxa->num != num; j--) { + if (--cnt) + rxa++; + else { + cnt = lst->count; + rxa = lst->items; + } + } } if (!cnt || rxa->num != num) { rprintf(FERROR, "[%s] could not find xattr #%d for %s\n",