From f603b1e17ebdc4f7e88699ca9376e741717bf254 Mon Sep 17 00:00:00 2001 From: Michal Ruprich Date: Mon, 31 May 2021 12:36:18 +0200 Subject: [PATCH] Resolves: #1955008 - rsync segfaults in --append mode when file on sender is large (> 2GB) and gets truncated --- rsync-3.2.3-append-mode.patch | 36 +++++++++++++++++++++++++++++++++++ rsync.spec | 7 ++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 rsync-3.2.3-append-mode.patch diff --git a/rsync-3.2.3-append-mode.patch b/rsync-3.2.3-append-mode.patch new file mode 100644 index 0000000..aa5645f --- /dev/null +++ b/rsync-3.2.3-append-mode.patch @@ -0,0 +1,36 @@ +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 (IS_DEVICE(st.st_mode) && st.st_size == 0) + st.st_size = get_device_size(fd, fname); + diff --git a/rsync.spec b/rsync.spec index c570ebe..917610a 100644 --- a/rsync.spec +++ b/rsync.spec @@ -10,7 +10,7 @@ Summary: A program for synchronizing files over a network Name: rsync Version: 3.2.3 -Release: 6%{?dist} +Release: 7%{?dist} URL: https://rsync.samba.org/ Source0: https://download.samba.org/pub/rsync/src/rsync-%{version}%{?prerelease}.tar.gz @@ -34,6 +34,7 @@ Patch0: rsync-3.2.2-ssl-verify-hostname.patch #Added due to rhbz#1873975 - default-acls test fail on s390x due to libacl Patch1: rsync-3.2.2-runtests.patch Patch2: rsync-3.2.3-lchmod.patch +Patch3: rsync-3.2.3-append-mode.patch %description Rsync uses a reliable algorithm to bring remote and host files into @@ -70,6 +71,7 @@ patch -p1 -i patches/copy-devices.diff %patch0 -p1 -b .verify-hostname %patch1 -p1 -b .runtests %patch2 -p1 -b .lchmod +%patch3 -p1 -b .append-mode %build %configure --disable-xxhash @@ -116,6 +118,9 @@ install -D -m644 %{SOURCE6} $RPM_BUILD_ROOT/%{_unitdir}/rsyncd@.service %systemd_postun_with_restart rsyncd.service %changelog +* Mon May 31 2021 Michal Ruprich - 3.2.3-7 +- Resolves: #1955008 - rsync segfaults in --append mode when file on sender is large (> 2GB) and gets truncated + * Fri Apr 16 2021 Mohan Boddu - 3.2.3-6 - Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937