summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2022-08-08 21:18:10 -0700
committerWayne Davison <wayne@opencoder.net>2022-08-08 21:18:10 -0700
commit685bf5804691d4af779a4deac28c7fbcf52b5009 (patch)
tree70b2363eb1fccb39a8adda386cc74ae0c61b5bee
parent9e2921fce8c518e370c324407d35bc83ba12f2d5 (diff)
downloadrsync-685bf5804691d4af779a4deac28c7fbcf52b5009.tar.gz
Handle files-from args that span 2 buffers.
-rw-r--r--exclude.c30
-rw-r--r--io.c3
2 files changed, 33 insertions, 0 deletions
diff --git a/exclude.c b/exclude.c
index d811dd1f..2394023f 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;
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