Synopsis:       Openrsync fails if source in rsync://host:port format w/ port
Category:       user
Environment:
        System      : OpenBSD 7.2
Description:

Hi guys!

Openrsync has a bug in the code that when you specify a port in the rsync://host:port -syntax, the module name gets wrong (port number is still there).

Best explained with an example where the rsync protocol runs at port 2873

# openrsync -na rsync://example.com:2873/openbsd-ports/audio /home/ports
rsync: [sender] change_dir "/2873/openbsd-ports" (in openbsd-ports) failed: No such file or directory (2)

I've added a diff that seems to work. A bit lazy but should show basically what needs to be done. :)

BR,
Dennis Lindroos

Fix:

Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/rsync/main.c,v
retrieving revision 1.65
diff -u -p -u -r1.65 main.c
--- main.c      2 Aug 2022 20:01:12 -0000       1.65
+++ main.c      8 Nov 2022 21:05:32 -0000
@@ -19,6 +19,7 @@
 #include <sys/wait.h>

 #include <assert.h>
+#include <ctype.h>
 #include <err.h>
 #include <getopt.h>
 #include <stdint.h>
@@ -239,6 +240,10 @@ fargs_parse(size_t argc, char *argv[], s
                            (cp[len] != '/' && cp[len] != '\0'))
                                errx(ERR_SYNTAX, "different remote host: %s",
                                    f->sources[i]);
+                       if (ccp) {
+                               while (isdigit(*++ccp));
+                               len = ccp - cp;
+                       }
                        memmove(f->sources[i],
                                f->sources[i] + len + 8 + 1,
                                j - len - 8);

Reply via email to