./configure (optional if already run)
make
-based-on: a6bdf313f239cabfef445bc3658b79aec8a40c37
+based-on: 35d4f6737a57c88978b6e954506e9c73f8c10ccf
diff --git a/Makefile.in b/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
popt/popthelp.o popt/poptparse.o
OBJS=$(OBJS1) $(OBJS2) $(OBJS3) @SIMD@ $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ @BUILD_POPT@
--TLS_OBJ = tls.o syscall.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
-+TLS_OBJ = tls.o syscall.o util.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o lib/wildmatch.o @BUILD_POPT@
+-TLS_OBJ = tls.o syscall.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
++TLS_OBJ = tls.o syscall.o util1.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o lib/wildmatch.o @BUILD_POPT@
# Programs we must have to run the test cases
CHECK_PROGS = rsync$(EXEEXT) tls$(EXEEXT) getgroups$(EXEEXT) getfsdev$(EXEEXT) \
getfsdev$(EXEEXT): getfsdev.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ getfsdev.o $(LIBS)
--TRIMSLASH_OBJ = trimslash.o syscall.o t_stub.o lib/compat.o lib/snprintf.o
-+TRIMSLASH_OBJ = trimslash.o syscall.o util.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/wildmatch.o
+-TRIMSLASH_OBJ = trimslash.o syscall.o util2.o t_stub.o lib/compat.o lib/snprintf.o
++TRIMSLASH_OBJ = trimslash.o syscall.o util1.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/wildmatch.o
trimslash$(EXEEXT): $(TRIMSLASH_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TRIMSLASH_OBJ) $(LIBS)
--compress, -z compress file data during the transfer
--compress-choice=STR choose the compression algorithm (aka --zc)
--compress-level=NUM explicitly set compression level (aka --zl)
-@@ -2343,6 +2344,17 @@ your home directory (remove the '=' for that).
+@@ -2347,6 +2348,17 @@ your home directory (remove the '=' for that).
specified (or implied by `-a`). You can work-around this bug by avoiding
the `-o` option when sending to an old rsync.
diff --git a/syscall.c b/syscall.c
--- a/syscall.c
+++ b/syscall.c
-@@ -142,6 +142,54 @@ int do_link(const char *old_path, const char *new_path)
+@@ -146,6 +146,54 @@ int do_link(const char *old_path, const char *new_path)
}
#endif
--- /dev/null
+This patch adds a safety check to prevent an xxhash 0.7 lib from being used to
+perform xxh3 checksums.
+
+To use this patch, run these commands for a successful build:
+
+ patch -p1 <patches/xxh3-safety-check.diff
+ make
+
+based-on: 35d4f6737a57c88978b6e954506e9c73f8c10ccf
+diff --git a/checksum.c b/checksum.c
+--- a/checksum.c
++++ b/checksum.c
+@@ -62,6 +62,8 @@ struct name_num_obj valid_checksums = {
+ int xfersum_type = 0; /* used for the file transfer checksums */
+ int checksum_type = 0; /* used for the pre-transfer (--checksum) checksums */
+
++static int initialized_choices = 0;
++
+ int parse_csum_name(const char *name, int len)
+ {
+ struct name_num_item *nni;
+@@ -79,6 +81,9 @@ int parse_csum_name(const char *name, int len)
+ return CSUM_MD4_ARCHAIC;
+ }
+
++ if (!initialized_choices)
++ init_checksum_choices();
++
+ nni = get_nni_by_name(&valid_checksums, name, len);
+
+ if (!nni) {
+@@ -623,3 +628,31 @@ int sum_end(char *sum)
+
+ return csum_len_for_type(cursum_type, 0);
+ }
++
++void init_checksum_choices()
++{
++#ifdef SUPPORT_XXH3
++ char buf[32816];
++ int j;
++ for (j = 0; j < (int)sizeof buf; j++) {
++ buf[j] = ' ' + (j % 96);
++ }
++ sum_init(CSUM_XXH3_64, 0);
++ sum_update(buf, 32816);
++ sum_update(buf, 31152);
++ sum_update(buf, 32474);
++ sum_update(buf, 9322);
++ if (XXH3_64bits_digest(xxh3_state) != 0xadbcf16d4678d1de) {
++ int t, f;
++ struct name_num_item *nni = valid_checksums.list;
++ for (t = f = 0; nni[f].name; f++) {
++ if (nni[f].num == CSUM_XXH3_64 || nni[f].num == CSUM_XXH3_128)
++ continue;
++ if (t != f)
++ nni[t++] = nni[f];
++ }
++ nni[t].name = NULL;
++ }
++#endif
++ initialized_choices = 1;
++}
+diff --git a/compat.c b/compat.c
+--- a/compat.c
++++ b/compat.c
+@@ -521,6 +521,8 @@ static void negotiate_the_strings(int f_in, int f_out)
+ {
+ /* We send all the negotiation strings before we start to read them to help avoid a slow startup. */
+
++ init_checksum_choices();
++
+ if (!checksum_choice)
+ send_negotiate_str(f_out, &valid_checksums, NSTR_CHECKSUM);
+
+diff --git a/usage.c b/usage.c
+--- a/usage.c
++++ b/usage.c
+@@ -190,6 +190,8 @@ void print_rsync_version(enum logcode f)
+
+ print_info_flags(f);
+
++ init_checksum_choices();
++
+ rprintf(f, "Checksum list:\n");
+ get_default_nno_list(&valid_checksums, tmpbuf, sizeof tmpbuf, '(');
+ rprintf(f, " %s\n", tmpbuf);