From: Wayne Davison Date: Mon, 21 Sep 2020 21:40:23 +0000 (-0700) Subject: Skip an append if sender's file gets shorter. X-Git-Tag: v3.2.4pre1~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9cd85b849672c93c4b1f534898585f92ec4de30d;p=thirdparty%2Frsync.git Skip an append if sender's file gets shorter. Fixes bug #90. Similar to a pull request by Tomas Korbar. --- diff --git a/NEWS.md b/NEWS.md index 87119e4c..405e86d1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,10 @@ for files that are being skipped due to an identical modify time. (This was a new output quirk in 3.2.3.) + - When doing an append transfer, the sending side's file must not get shorter + or it is skipped. Fixes a crash that could occur when the size changes to 0 + in the middle of the send negotiations. + - Avoid a weird failure if you run a local copy with a (useless) `--rsh` option that contains a `V`. diff --git a/rsync.1.md b/rsync.1.md index ec971ecc..7bb4c5a1 100644 --- a/rsync.1.md +++ b/rsync.1.md @@ -949,7 +949,9 @@ your home directory (remove the '=' for that). existing content in the file (it only verifies the content that it is appending). Rsync skips any files that exist on the receiving side that are not shorter than the associated file on the sending side (which means - that new files are trasnferred). + that new files are trasnferred). It also skips any files whose size on the + sending side gets shorter during the send negotiations (rsync warns about a + "diminished" file when this happens). This does not interfere with the updating of a file's non-content attributes (e.g. permissions, ownership, etc.) when the file does not need diff --git a/sender.c b/sender.c index 94761c26..9cfca134 100644 --- a/sender.c +++ b/sender.c @@ -362,6 +362,16 @@ void send_files(int f_in, int f_out) exit_cleanup(RERR_FILEIO); } + if (append_mode > 0 && st.st_size < F_LENGTH(file)) { + rprintf(FWARNING, "skipped diminished file: %s\n", + full_fname(fname)); + free_sums(s); + close(fd); + if (protocol_version >= 30) + send_msg_int(MSG_NO_SEND, ndx); + continue; + } + if (st.st_size) { int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE); mbuf = map_file(fd, st.st_size, read_size, s->blength);