diff options
Diffstat (limited to 'meta/recipes-extended/cpio/cpio-2.12/0001-Fix-CVE-2015-1197.patch')
-rw-r--r-- | meta/recipes-extended/cpio/cpio-2.12/0001-Fix-CVE-2015-1197.patch | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/meta/recipes-extended/cpio/cpio-2.12/0001-Fix-CVE-2015-1197.patch b/meta/recipes-extended/cpio/cpio-2.12/0001-Fix-CVE-2015-1197.patch new file mode 100644 index 0000000000..8f719ad8d6 --- /dev/null +++ b/meta/recipes-extended/cpio/cpio-2.12/0001-Fix-CVE-2015-1197.patch | |||
@@ -0,0 +1,177 @@ | |||
1 | From dcee489f821c1260a0136fcdfdb6ff4dd11086ac Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexander Kanavin <alex.kanavin@gmail.com> | ||
3 | Date: Wed, 9 Dec 2015 17:58:03 +0200 | ||
4 | Subject: [PATCH] Fix CVE-2015-1197 | ||
5 | |||
6 | Apply patch by Vitezslav Cizek of SuSE to fix CVE-2015-1197. | ||
7 | Upstream is dormant or no longer existing. To restore the old | ||
8 | behaviour use --extract-over-symlinks (Closes: #774669) | ||
9 | This issue has been discovered by Alexander Cherepanov. | ||
10 | Author: Vitezslav Cizek <vcizek@suse.cz> | ||
11 | Bug-Debian: https://bugs.debian.org/774669 | ||
12 | |||
13 | Upstream-Status: Pending | ||
14 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
15 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> | ||
16 | |||
17 | --- | ||
18 | doc/cpio.1 | 1 + | ||
19 | src/copyin.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
20 | src/extern.h | 1 + | ||
21 | src/global.c | 3 +++ | ||
22 | src/main.c | 7 +++++++ | ||
23 | 5 files changed, 74 insertions(+) | ||
24 | |||
25 | diff --git a/doc/cpio.1 b/doc/cpio.1 | ||
26 | index 2a68241..dc4676c 100644 | ||
27 | --- a/doc/cpio.1 | ||
28 | +++ b/doc/cpio.1 | ||
29 | @@ -49,6 +49,7 @@ cpio \- copy files to and from archives | ||
30 | [\fB\-\-no\-preserve\-owner\fR] [\fB\-\-message=\fIMESSAGE\fR] | ||
31 | [\fB\-\-force\-local\fR] [\fB\-\-no\-absolute\-filenames\fR] [\fB\-\-sparse\fR] | ||
32 | [\fB\-\-only\-verify\-crc\fR] [\fB\-\-to\-stdout\fR] [\fB\-\-quiet\fR] | ||
33 | +[\fB\-\-extract\-over\-symlinks\fR] | ||
34 | [\fB\-\-rsh\-command=\fICOMMAND\fR] | ||
35 | [\fIpattern\fR...] [\fB<\fR \fIarchive\fR] | ||
36 | |||
37 | diff --git a/src/copyin.c b/src/copyin.c | ||
38 | index cde911e..053afe7 100644 | ||
39 | --- a/src/copyin.c | ||
40 | +++ b/src/copyin.c | ||
41 | @@ -695,6 +695,51 @@ copyin_link (struct cpio_file_stat *file_hdr, int in_file_des) | ||
42 | free (link_name); | ||
43 | } | ||
44 | |||
45 | + | ||
46 | +static int | ||
47 | +path_contains_symlink(char *path) | ||
48 | +{ | ||
49 | + struct stat st; | ||
50 | + char *slash; | ||
51 | + char *nextslash; | ||
52 | + | ||
53 | + /* we got NULL pointer or empty string */ | ||
54 | + if (!path || !*path) { | ||
55 | + return false; | ||
56 | + } | ||
57 | + | ||
58 | + slash = path; | ||
59 | + | ||
60 | + while ((nextslash = strchr(slash + 1, '/')) != NULL) { | ||
61 | + slash = nextslash; | ||
62 | + *slash = '\0'; | ||
63 | + | ||
64 | + if (lstat(path, &st) != 0) { | ||
65 | + if (errno == ELOOP) { | ||
66 | + /* ELOOP - too many symlinks */ | ||
67 | + *slash = '/'; | ||
68 | + return true; | ||
69 | + } else if (errno == ENOMEM) { | ||
70 | + /* No memory for lstat - terminate */ | ||
71 | + xalloc_die(); | ||
72 | + } else { | ||
73 | + /* cannot lstat path - give up */ | ||
74 | + *slash = '/'; | ||
75 | + return false; | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | + if (S_ISLNK(st.st_mode)) { | ||
80 | + *slash = '/'; | ||
81 | + return true; | ||
82 | + } | ||
83 | + | ||
84 | + *slash = '/'; | ||
85 | + } | ||
86 | + | ||
87 | + return false; | ||
88 | +} | ||
89 | + | ||
90 | static void | ||
91 | copyin_file (struct cpio_file_stat *file_hdr, int in_file_des) | ||
92 | { | ||
93 | @@ -1468,6 +1513,23 @@ process_copy_in () | ||
94 | { | ||
95 | /* Copy the input file into the directory structure. */ | ||
96 | |||
97 | + /* Can we write files over symlinks? */ | ||
98 | + if (!extract_over_symlinks) | ||
99 | + { | ||
100 | + if (path_contains_symlink(file_hdr.c_name)) | ||
101 | + { | ||
102 | + /* skip the file */ | ||
103 | + /* | ||
104 | + fprintf(stderr, "Can't write over symlinks. Skipping %s\n", file_hdr.c_name); | ||
105 | + tape_toss_input (in_file_des, file_hdr.c_filesize); | ||
106 | + tape_skip_padding (in_file_des, file_hdr.c_filesize); | ||
107 | + continue; | ||
108 | + */ | ||
109 | + /* terminate */ | ||
110 | + error (1, 0, _("Can't write over symlinks: %s\n"), file_hdr.c_name); | ||
111 | + } | ||
112 | + } | ||
113 | + | ||
114 | /* Do we need to rename the file? */ | ||
115 | if (rename_flag || rename_batch_file) | ||
116 | { | ||
117 | diff --git a/src/extern.h b/src/extern.h | ||
118 | index e27d662..d864bde 100644 | ||
119 | --- a/src/extern.h | ||
120 | +++ b/src/extern.h | ||
121 | @@ -96,6 +96,7 @@ extern char input_is_special; | ||
122 | extern char output_is_special; | ||
123 | extern char input_is_seekable; | ||
124 | extern char output_is_seekable; | ||
125 | +extern bool extract_over_symlinks; | ||
126 | extern int (*xstat) (); | ||
127 | extern void (*copy_function) (); | ||
128 | extern char *change_directory_option; | ||
129 | diff --git a/src/global.c b/src/global.c | ||
130 | index 57e505a..336fce4 100644 | ||
131 | --- a/src/global.c | ||
132 | +++ b/src/global.c | ||
133 | @@ -187,6 +187,9 @@ bool to_stdout_option = false; | ||
134 | /* The name this program was run with. */ | ||
135 | char *program_name; | ||
136 | |||
137 | +/* Extract files over symbolic links */ | ||
138 | +bool extract_over_symlinks; | ||
139 | + | ||
140 | /* A pointer to either lstat or stat, depending on whether | ||
141 | dereferencing of symlinks is done for input files. */ | ||
142 | int (*xstat) (); | ||
143 | diff --git a/src/main.c b/src/main.c | ||
144 | index a13861f..87cb309 100644 | ||
145 | --- a/src/main.c | ||
146 | +++ b/src/main.c | ||
147 | @@ -59,6 +59,7 @@ enum cpio_options { | ||
148 | DEBUG_OPTION, | ||
149 | BLOCK_SIZE_OPTION, | ||
150 | TO_STDOUT_OPTION, | ||
151 | + EXTRACT_OVER_SYMLINKS, | ||
152 | RENUMBER_INODES_OPTION, | ||
153 | IGNORE_DEVNO_OPTION, | ||
154 | DEVICE_INDEPENDENT_OPTION | ||
155 | @@ -243,6 +244,8 @@ static struct argp_option options[] = { | ||
156 | N_("Create leading directories where needed"), GRID+1 }, | ||
157 | {"no-preserve-owner", NO_PRESERVE_OWNER_OPTION, 0, 0, | ||
158 | N_("Do not change the ownership of the files"), GRID+1 }, | ||
159 | + {"extract-over-symlinks", EXTRACT_OVER_SYMLINKS, 0, 0, | ||
160 | + N_("Force writing over symbolic links"), GRID+1 }, | ||
161 | {"unconditional", 'u', NULL, 0, | ||
162 | N_("Replace all files unconditionally"), GRID+1 }, | ||
163 | {"sparse", SPARSE_OPTION, NULL, 0, | ||
164 | @@ -432,6 +435,10 @@ crc newc odc bin ustar tar (all-caps also recognized)"), arg)); | ||
165 | no_chown_flag = true; | ||
166 | break; | ||
167 | |||
168 | + case EXTRACT_OVER_SYMLINKS: /* --extract-over-symlinks */ | ||
169 | + extract_over_symlinks = true; | ||
170 | + break; | ||
171 | + | ||
172 | case 'o': /* Copy-out mode. */ | ||
173 | if (copy_function != 0) | ||
174 | USAGE_ERROR ((0, 0, _("Mode already defined"))); | ||
175 | -- | ||
176 | 2.6.2 | ||
177 | |||