aboutsummaryrefslogtreecommitdiff
path: root/patches/rsync/rsync-2.6.9.diff
blob: 26805ef4a11f4bebd273717eb5e2af70327958eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--- rsync-2.6.9.orig/sender.c
+++ rsync-2.6.9/sender.c
@@ -123,6 +123,7 @@
 	char fname[MAXPATHLEN];
 	struct file_struct *file;
 	unsigned int offset;
+	size_t l = 0;
 
 	if (ndx < 0 || ndx >= the_file_list->count)
 		return;
@@ -133,6 +134,20 @@
 				    file->dir.root, "/", NULL);
 	} else
 		offset = 0;
+
+	l = offset + 1;
+	if (file) {
+		if (file->dirname)
+			l += strlen(file->dirname);
+		if (file->basename)
+			l += strlen(file->basename);
+	}
+
+	if (l >= sizeof(fname)) {
+		rprintf(FERROR, "Overlong pathname\n");
+		exit_cleanup(RERR_FILESELECT);
+	}
+
 	f_name(file, fname + offset);
 	if (remove_source_files) {
 		if (do_unlink(fname) == 0) {
@@ -224,6 +239,7 @@
 	enum logcode log_code = log_before_transfer ? FLOG : FINFO;
 	int f_xfer = write_batch < 0 ? batch_fd : f_out;
 	int i, j;
+	size_t l = 0;
 
 	if (verbose > 2)
 		rprintf(FINFO, "send_files starting\n");
@@ -259,6 +275,20 @@
 				fname[offset++] = '/';
 		} else
 			offset = 0;
+
+		l = offset + 1;
+		if (file) {
+			if (file->dirname)
+				l += strlen(file->dirname);
+			if (file->basename)
+				l += strlen(file->basename);
+		}
+
+		if (l >= sizeof(fname)) {
+			rprintf(FERROR, "Overlong pathname\n");
+			exit_cleanup(RERR_FILESELECT);
+		}
+
 		fname2 = f_name(file, fname + offset);
 
 		if (verbose > 2)