[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Tue Aug 9 04:39:03 UTC 2022


The branch, master has been updated
       via  fabef23b Fix --relative when copying an absolute path.
       via  685bf580 Handle files-from args that span 2 buffers.
      from  9e2921fc A fix for the zlib fix.

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fabef23bea6e9963c06e218586fda1a823e3c6bf
Author: Wayne Davison <wayne at opencoder.net>
Date:   Mon Aug 8 21:30:21 2022 -0700

    Fix --relative when copying an absolute path.

commit 685bf5804691d4af779a4deac28c7fbcf52b5009
Author: Wayne Davison <wayne at opencoder.net>
Date:   Mon Aug 8 21:18:10 2022 -0700

    Handle files-from args that span 2 buffers.

-----------------------------------------------------------------------

Summary of changes:
 exclude.c | 34 +++++++++++++++++++++++++++++++++-
 io.c      |  3 +++
 2 files changed, 36 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/exclude.c b/exclude.c
index d811dd1f..ba5ca5a3 100644
--- a/exclude.c
+++ b/exclude.c
@@ -349,6 +349,28 @@ static void maybe_add_literal_brackets_rule(filter_rule const *based_on, int arg
 	}
 }
 
+static char *partial_string_buf = NULL;
+static int partial_string_len = 0;
+void implied_include_partial_string(const char *s_start, const char *s_end)
+{
+	partial_string_len = s_end - s_start;
+	if (partial_string_len <= 0 || partial_string_len >= MAXPATHLEN) { /* too-large should be impossible... */
+		partial_string_len = 0;
+		return;
+	}
+	if (!partial_string_buf)
+		partial_string_buf = new_array(char, MAXPATHLEN);
+	memcpy(partial_string_buf, s_start, partial_string_len);
+}
+
+void free_implied_include_partial_string()
+{
+	if (partial_string_buf) {
+		free(partial_string_buf);
+		partial_string_buf = NULL;
+	}
+}
+
 /* Each arg the client sends to the remote sender turns into an implied include
  * that the receiver uses to validate the file list from the sender. */
 void add_implied_include(const char *arg)
@@ -360,6 +382,14 @@ void add_implied_include(const char *arg)
 	char *p;
 	if (am_server || old_style_args || list_only || read_batch || filesfrom_host != NULL)
 		return;
+	if (partial_string_len) {
+		arg_len = strlen(arg);
+		if (partial_string_len + arg_len >= MAXPATHLEN)
+			return; /* Should be impossible... */
+		memcpy(partial_string_buf + partial_string_len, arg, arg_len + 1);
+		partial_string_len = 0;
+		arg = partial_string_buf;
+	}
 	if (relative_paths) {
 		if ((cp = strstr(arg, "/./")) != NULL)
 			arg = cp + 3;
@@ -404,8 +434,10 @@ void add_implied_include(const char *arg)
 				*p++ = *cp++;
 				break;
 			  case '/':
-				if (p[-1] == '/') /* This is safe because of the initial slash. */
+				if (p[-1] == '/') { /* This is safe because of the initial slash. */
+					cp++;
 					break;
+				}
 				if (relative_paths) {
 					filter_rule const *ent;
 					int found = 0;
diff --git a/io.c b/io.c
index a6e3ed30..7111878a 100644
--- a/io.c
+++ b/io.c
@@ -376,6 +376,7 @@ static void forward_filesfrom_data(void)
 			free_xbuf(&ff_xb);
 			if (ff_reenable_multiplex >= 0)
 				io_start_multiplex_out(ff_reenable_multiplex);
+			free_implied_include_partial_string();
 		}
 		return;
 	}
@@ -435,6 +436,7 @@ static void forward_filesfrom_data(void)
 			ff_lastchar = '\0';
 		else {
 			/* Handle a partial string specially, saving any incomplete chars. */
+			implied_include_partial_string(sob, s);
 			flags &= ~ICB_INCLUDE_INCOMPLETE;
 			if (iconvbufs(ic_send, &ff_xb, &iobuf.out, flags) < 0) {
 				if (errno == E2BIG)
@@ -461,6 +463,7 @@ static void forward_filesfrom_data(void)
 					f++;
 			}
 		}
+		implied_include_partial_string(cur, t);
 		ff_lastchar = f[-1];
 		if ((len = t - ff_xb.buf) != 0) {
 			/* This will not circle back to perform_io() because we only get


-- 
The rsync repository.



More information about the rsync-cvs mailing list