diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-22 16:37:01 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-22 16:37:01 +0200 |
commit | a96074874857b31361d02ead97a1152164568918 (patch) | |
tree | 99a7c0af22fa222f1f944da702e4350f65b37a01 /testsuite | |
parent | accd9eeb719916da974584b33b1aeced5f3bb346 (diff) | |
download | busybox-w32-a96074874857b31361d02ead97a1152164568918.tar.gz busybox-w32-a96074874857b31361d02ead97a1152164568918.tar.bz2 busybox-w32-a96074874857b31361d02ead97a1152164568918.zip |
tar: add a test that we don't write into symlinks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/tar.tests | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tar.tests b/testsuite/tar.tests index 383a4646c..890a73dd5 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests | |||
@@ -256,6 +256,49 @@ Ok | |||
256 | "" "" | 256 | "" "" |
257 | SKIP= | 257 | SKIP= |
258 | 258 | ||
259 | # attack.tar.bz2 has symlink pointing to a system file | ||
260 | # followed by a regular file with the same name | ||
261 | # containing "root::0:0::/root:/bin/sh": | ||
262 | # lrwxrwxrwx root/root passwd -> /tmp/passwd | ||
263 | # -rw-r--r-- root/root passwd | ||
264 | # naive tar implementation may end up creating the symlink | ||
265 | # and then writing into it. | ||
266 | # The correct implementation unlinks target before | ||
267 | # creating the second file. | ||
268 | # We test that /tmp/passwd remains empty: | ||
269 | optional UUDECODE FEATURE_SEAMLESS_BZ2 | ||
270 | testing "tar does not extract into symlinks" "\ | ||
271 | >>/tmp/passwd && uudecode -o input && tar xf input 2>&1 && rm passwd; cat /tmp/passwd; echo \$? | ||
272 | " "\ | ||
273 | 0 | ||
274 | " \ | ||
275 | "" "\ | ||
276 | begin-base64 644 attack.tar.bz2 | ||
277 | QlpoOTFBWSZTWRVn/bIAAKt7hMqwAEBAAP2QAhB0Y96AAACACCAAlISgpqe0 | ||
278 | po0DIaDynqAkpDRP1ANAhiYNSPR8VchKhAz0AK59+DA6FcMKBggOARIJdVHL | ||
279 | DGllrjs20ATUgR1HmccBX3EhoMnpMJaNyggmxgLDMz54lBnBTJO/1L1lbMS4 | ||
280 | l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI= | ||
281 | ==== | ||
282 | " | ||
283 | SKIP= | ||
284 | # And same with -k | ||
285 | optional UUDECODE FEATURE_SEAMLESS_BZ2 | ||
286 | testing "tar -k does not extract into symlinks" "\ | ||
287 | >>/tmp/passwd && uudecode -o input && tar xf input -k 2>&1 && rm passwd; cat /tmp/passwd; echo \$? | ||
288 | " "\ | ||
289 | tar: can't open 'passwd': File exists | ||
290 | 0 | ||
291 | " \ | ||
292 | "" "\ | ||
293 | begin-base64 644 attack.tar.bz2 | ||
294 | QlpoOTFBWSZTWRVn/bIAAKt7hMqwAEBAAP2QAhB0Y96AAACACCAAlISgpqe0 | ||
295 | po0DIaDynqAkpDRP1ANAhiYNSPR8VchKhAz0AK59+DA6FcMKBggOARIJdVHL | ||
296 | DGllrjs20ATUgR1HmccBX3EhoMnpMJaNyggmxgLDMz54lBnBTJO/1L1lbMS4 | ||
297 | l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI= | ||
298 | ==== | ||
299 | " | ||
300 | SKIP= | ||
301 | |||
259 | 302 | ||
260 | cd .. && rm -rf tar.tempdir || exit 1 | 303 | cd .. && rm -rf tar.tempdir || exit 1 |
261 | 304 | ||