Просмотр исходного кода

rsync: patch CVE-2014-9512

Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
Maxim Storchak 10 лет назад
Родитель
Сommit
6e9b8e6a52
2 измененных файлов: 107 добавлений и 1 удалений
  1. 1
    1
      net/rsync/Makefile
  2. 106
    0
      net/rsync/patches/000-CVE-2014-9512.patch

+ 1
- 1
net/rsync/Makefile Просмотреть файл

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=rsync
11 11
 PKG_VERSION:=3.1.1
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 
14 14
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 15
 PKG_SOURCE_URL:=http://rsync.samba.org/ftp/rsync/src

+ 106
- 0
net/rsync/patches/000-CVE-2014-9512.patch Просмотреть файл

@@ -0,0 +1,106 @@
1
+From: Wayne Davison <wayned@samba.org>
2
+Date: Wed, 31 Dec 2014 20:41:03 +0000 (-0800)
3
+Subject: Complain if an inc-recursive path is not right for its dir.
4
+X-Git-Url: https://git.samba.org/?p=rsync.git;a=commitdiff_plain;h=962f8b90045ab331fc04c9e65f80f1a53e68243b
5
+
6
+Complain if an inc-recursive path is not right for its dir.
7
+This ensures that a malicious sender can't use a just-sent
8
+symlink as a trasnfer path.
9
+---
10
+
11
+diff --git a/flist.c b/flist.c
12
+index c24672e..92e4b65 100644
13
+--- a/flist.c
14
++++ b/flist.c
15
+@@ -2435,8 +2435,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
16
+ 	return flist;
17
+ }
18
+ 
19
+-struct file_list *recv_file_list(int f)
20
++struct file_list *recv_file_list(int f, int dir_ndx)
21
+ {
22
++	const char *good_dirname = NULL;
23
+ 	struct file_list *flist;
24
+ 	int dstart, flags;
25
+ 	int64 start_read;
26
+@@ -2492,6 +2493,23 @@ struct file_list *recv_file_list(int f)
27
+ 		flist_expand(flist, 1);
28
+ 		file = recv_file_entry(f, flist, flags);
29
+ 
30
++		if (inc_recurse) {
31
++			static const char empty_dir[] = "\0";
32
++			const char *cur_dir = file->dirname ? file->dirname : empty_dir;
33
++			if (relative_paths && *cur_dir == '/')
34
++				cur_dir++;
35
++			if (cur_dir != good_dirname) {
36
++				const char *d = dir_ndx >= 0 ? f_name(dir_flist->files[dir_ndx], NULL) : empty_dir;
37
++				if (strcmp(cur_dir, d) != 0) {
38
++					rprintf(FERROR,
39
++						"ABORTING due to invalid dir prefix from sender: %s (should be: %s)\n",
40
++						cur_dir, d);
41
++					exit_cleanup(RERR_PROTOCOL);
42
++				}
43
++				good_dirname = cur_dir;
44
++			}
45
++		}
46
++
47
+ 		if (S_ISREG(file->mode)) {
48
+ 			/* Already counted */
49
+ 		} else if (S_ISDIR(file->mode)) {
50
+@@ -2615,7 +2633,7 @@ void recv_additional_file_list(int f)
51
+ 			rprintf(FINFO, "[%s] receiving flist for dir %d\n",
52
+ 				who_am_i(), ndx);
53
+ 		}
54
+-		flist = recv_file_list(f);
55
++		flist = recv_file_list(f, ndx);
56
+ 		flist->parent_ndx = ndx;
57
+ 	}
58
+ }
59
+diff --git a/io.c b/io.c
60
+index b9a9bd0..a868fa9 100644
61
+--- a/io.c
62
++++ b/io.c
63
+@@ -1685,7 +1685,7 @@ void wait_for_receiver(void)
64
+ 				rprintf(FINFO, "[%s] receiving flist for dir %d\n",
65
+ 					who_am_i(), ndx);
66
+ 			}
67
+-			flist = recv_file_list(iobuf.in_fd);
68
++			flist = recv_file_list(iobuf.in_fd, ndx);
69
+ 			flist->parent_ndx = ndx;
70
+ #ifdef SUPPORT_HARD_LINKS
71
+ 			if (preserve_hard_links)
72
+diff --git a/main.c b/main.c
73
+index e7a13f7..713b818 100644
74
+--- a/main.c
75
++++ b/main.c
76
+@@ -1009,7 +1009,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
77
+ 		filesfrom_fd = -1;
78
+ 	}
79
+ 
80
+-	flist = recv_file_list(f_in);
81
++	flist = recv_file_list(f_in, -1);
82
+ 	if (!flist) {
83
+ 		rprintf(FERROR,"server_recv: recv_file_list error\n");
84
+ 		exit_cleanup(RERR_FILESELECT);
85
+@@ -1183,7 +1183,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
86
+ 
87
+ 	if (write_batch && !am_server)
88
+ 		start_write_batch(f_in);
89
+-	flist = recv_file_list(f_in);
90
++	flist = recv_file_list(f_in, -1);
91
+ 	if (inc_recurse && file_total == 1)
92
+ 		recv_additional_file_list(f_in);
93
+ 
94
+diff --git a/rsync.c b/rsync.c
95
+index 68ff6b1..c3ecc51 100644
96
+--- a/rsync.c
97
++++ b/rsync.c
98
+@@ -364,7 +364,7 @@ int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr,
99
+ 		}
100
+ 		/* Send all the data we read for this flist to the generator. */
101
+ 		start_flist_forward(ndx);
102
+-		flist = recv_file_list(f_in);
103
++		flist = recv_file_list(f_in, ndx);
104
+ 		flist->parent_ndx = ndx;
105
+ 		stop_flist_forward();
106
+ 	}