Bug 14323 - Defaults for --skip-compress are not working, everything is being compressed
Summary: Defaults for --skip-compress are not working, everything is being compressed
Status: RESOLVED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.3
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-20 13:29 UTC by Simon Matter
Modified: 2020-04-08 01:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Matter 2020-03-20 13:29:34 UTC
By default certain file suffixes should not be compressed while rsyncing from remote host. This worked fine for 3.0.6 but doesn't for 3.1.3.

In my tests I named an ascii text file as z.gz and rsynced it:

[simix@alpha Z]$ rsync-3.0.6/rsync --rsync-path=${PWD}/rsync-3.0.6/rsync -azv alpha:Z/z.gz Z ; rm -vf Z
simix@alpha's password: 
receiving incremental file list
z.gz

sent 30 bytes  received 629254 bytes  83904.53 bytes/sec
total size is 628952  speedup is 1.00
removed ‘Z’

[simix@alpha Z]$ rsync-3.1.3/rsync --rsync-path=${PWD}/rsync-3.1.3/rsync -azv alpha:Z/z.gz Z ; rm -vf Z
simix@alpha's password: 
receiving incremental file list
z.gz

sent 43 bytes  received 63,873 bytes  18,261.71 bytes/sec
total size is 628,952  speedup is 9.84
removed ‘Z’

As you can see the file was compressed on the fly with 3.1.3, which is wrong.

I'm wondering if the following change is the culprit here:

--- rsync-3.0.6/token.c 2009-01-17 22:41:35.000000000 +0100
+++ rsync-3.1.3/token.c 2018-01-15 04:55:07.000000000 +0100
@@ -45,12 +46,12 @@ static void add_suffix(struct suffix_tre

        if (ltr == '[') {
                const char *after = strchr(str, ']');
-               /* Just skip bogus character classes. */
-               if (!after++)
+               /* Treat "[foo" and "[]" as having a literal '['. */
+               if (after && after++ != str+1) {
+                       while ((ltr = *str++) != ']')
+                               add_suffix(prior, ltr, after);
                        return;
-               while ((ltr = *str++) != ']')
-                       add_suffix(prior, ltr, after);
-               return;
+               }
        }

        for (node = *prior; node; prior = &node->sibling, node = node->sibling) {


Kind regards,
Simon
Comment 1 Simon Matter 2020-03-22 09:58:07 UTC
Did some more tests and found the bug was introduced between 3.0.9 and 3.1.0.

It seems like handling of default values is not working as expected.
Comment 2 Wayne Davison 2020-04-08 01:20:07 UTC
The code actually grabs the default skip-compress list from the daemon's "dont compress" list, and in recent rsync versions the daemon vars were not initialized in a non-daemon run.  I've committed a fix.