~ubuntu-branches/ubuntu/wily/patch/wily

« back to all changes in this revision

Viewing changes to tests/symlinks

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2015-01-20 19:34:19 UTC
  • Revision ID: package-import@ubuntu.com-20150120193419-36scn81qbv98702k
Tags: 2.7.1-7
* Backport patches from upstream Git tree:
  - fix CVE-2015-119: directory traversal via symlinks (closes: #775227),
  - infinite loop while applying patch (closes: #775540),
  - segmentation fault while applying corrupted patch (closes: #775793).

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
 
147
147
# --------------------------------------------------------------
148
148
 
 
149
# Patch should not create symlinks which point outside the working directory.
 
150
 
 
151
cat > symlink-target.diff <<EOF
 
152
diff --git a/dir/foo b/dir/foo
 
153
new file mode 120000
 
154
index 0000000..cad2309
 
155
--- /dev/null
 
156
+++ b/dir/foo
 
157
@@ -0,0 +1 @@
 
158
+../foo
 
159
\ No newline at end of file
 
160
EOF
 
161
 
 
162
check 'patch -p1 < symlink-target.diff || echo "Status: $?"' <<EOF
 
163
patching symbolic link dir/foo
 
164
EOF
 
165
 
 
166
cat > bad-symlink-target1.diff <<EOF
 
167
diff --git a/bar b/bar
 
168
new file mode 120000
 
169
index 0000000..cad2309
 
170
--- /dev/null
 
171
+++ b/bar
 
172
@@ -0,0 +1 @@
 
173
+/bar
 
174
\ No newline at end of file
 
175
EOF
 
176
 
 
177
check 'patch -p1 < bad-symlink-target1.diff || echo "Status: $?"' <<EOF
 
178
patching symbolic link bar
 
179
symbolic link target '/bar' is invalid
 
180
Status: 2
 
181
EOF
 
182
 
 
183
cat > bad-symlink-target2.diff <<EOF
 
184
diff --git a/baz b/baz
 
185
new file mode 120000
 
186
index 0000000..cad2309
 
187
--- /dev/null
 
188
+++ b/baz
 
189
@@ -0,0 +1 @@
 
190
+../baz
 
191
\ No newline at end of file
 
192
EOF
 
193
 
 
194
check 'patch -p1 < bad-symlink-target2.diff || echo "Status: $?"' <<EOF
 
195
patching symbolic link baz
 
196
symbolic link target '../baz' is invalid
 
197
Status: 2
 
198
EOF
 
199
 
 
200
# --------------------------------------------------------------
 
201
 
149
202
# The backup file of a new symlink is an empty regular file.
150
203
 
151
204
check 'patch -p1 --backup < create-symlink.diff || echo "Status: $?"' <<EOF