Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
rsync.6845
0001-Complain-if-an-inc-recursive-path-is-not-r...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Complain-if-an-inc-recursive-path-is-not-right-for-i.patch of Package rsync.6845
From 962f8b90045ab331fc04c9e65f80f1a53e68243b Mon Sep 17 00:00:00 2001 From: Wayne Davison <wayned@samba.org> Date: Wed, 31 Dec 2014 12:41:03 -0800 Subject: [PATCH] Complain if an inc-recursive path is not right for its dir. This ensures that a malicious sender can't use a just-sent symlink as a trasnfer path. --- NEWS | 7 ++++++- flist.c | 22 ++++++++++++++++++++-- io.c | 2 +- main.c | 4 ++-- rsync.c | 2 +- 5 files changed, 30 insertions(+), 7 deletions(-) Index: rsync-3.1.0/flist.c =================================================================== --- rsync-3.1.0.orig/flist.c 2016-01-04 14:40:05.107024736 +0100 +++ rsync-3.1.0/flist.c 2016-01-04 14:40:08.628079436 +0100 @@ -2425,8 +2425,9 @@ struct file_list *send_file_list(int f, return flist; } -struct file_list *recv_file_list(int f) +struct file_list *recv_file_list(int f, int dir_ndx) { + const char *good_dirname = NULL; struct file_list *flist; int dstart, flags; int64 start_read; @@ -2482,6 +2483,23 @@ struct file_list *recv_file_list(int f) flist_expand(flist, 1); file = recv_file_entry(f, flist, flags); + if (inc_recurse) { + static const char empty_dir[] = "\0"; + const char *cur_dir = file->dirname ? file->dirname : empty_dir; + if (relative_paths && *cur_dir == '/') + cur_dir++; + if (cur_dir != good_dirname) { + const char *d = dir_ndx >= 0 ? f_name(dir_flist->files[dir_ndx], NULL) : empty_dir; + if (strcmp(cur_dir, d) != 0) { + rprintf(FERROR, + "ABORTING due to invalid dir prefix from sender: %s (should be: %s)\n", + cur_dir, d); + exit_cleanup(RERR_PROTOCOL); + } + good_dirname = cur_dir; + } + } + if (S_ISREG(file->mode)) { /* Already counted */ } else if (S_ISDIR(file->mode)) { @@ -2602,7 +2620,7 @@ void recv_additional_file_list(int f) rprintf(FINFO, "[%s] receiving flist for dir %d\n", who_am_i(), ndx); } - flist = recv_file_list(f); + flist = recv_file_list(f, ndx); flist->parent_ndx = ndx; } } Index: rsync-3.1.0/io.c =================================================================== --- rsync-3.1.0.orig/io.c 2016-01-04 14:40:05.107024736 +0100 +++ rsync-3.1.0/io.c 2016-01-04 14:40:08.629079451 +0100 @@ -1694,7 +1694,7 @@ void wait_for_receiver(void) rprintf(FINFO, "[%s] receiving flist for dir %d\n", who_am_i(), ndx); } - flist = recv_file_list(iobuf.in_fd); + flist = recv_file_list(iobuf.in_fd, ndx); flist->parent_ndx = ndx; #ifdef SUPPORT_HARD_LINKS if (preserve_hard_links) Index: rsync-3.1.0/main.c =================================================================== --- rsync-3.1.0.orig/main.c 2016-01-04 14:40:05.108024751 +0100 +++ rsync-3.1.0/main.c 2016-01-04 14:40:08.629079451 +0100 @@ -1009,7 +1009,7 @@ static void do_server_recv(int f_in, int filesfrom_fd = -1; } - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, -1); if (!flist) { rprintf(FERROR,"server_recv: recv_file_list error\n"); exit_cleanup(RERR_FILESELECT); @@ -1183,7 +1183,7 @@ int client_run(int f_in, int f_out, pid_ if (write_batch && !am_server) start_write_batch(f_in); - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, -1); if (inc_recurse && file_total == 1) recv_additional_file_list(f_in); Index: rsync-3.1.0/rsync.c =================================================================== --- rsync-3.1.0.orig/rsync.c 2016-01-04 14:40:05.108024751 +0100 +++ rsync-3.1.0/rsync.c 2016-01-04 14:40:08.629079451 +0100 @@ -364,7 +364,7 @@ int read_ndx_and_attrs(int f_in, int f_o } /* Send all the data we read for this flist to the generator. */ start_flist_forward(ndx); - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, ndx); flist->parent_ndx = ndx; stop_flist_forward(); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor