summaryrefslogtreecommitdiff
path: root/tests/symlinks
Commit message (Collapse)AuthorAgeFilesLines
* Allow absolute symlinks that lead back into the working directoryAndreas Gruenbacher2015-03-071-0/+26
| | | | | | | | | | * src/safe.c (cwd_stat_errno, cwd_stat): stat() result of ".". (read_symlink): When a symlink is absolute, check if it leads back into the working directory. If it does, strip off the prefix above the working directory. If the symlink points to the working directory, return an empty path. (traverse_another_path): Recognize empty paths from read_symlink(). * tests/symlinks: Absolute symlink test cases.
* Add more path traversal test casesTim Waugh2015-03-051-4/+123
| | | | * tests/symlinks: Add more path traversal test cases.
* Follow directory symlinks within the working directoryAndreas Gruenbacher2015-03-051-3/+7
| | | | | | | | | * src/safe.c (struct symlink): A symlink to resolve. (push_symlink, pop_symlink): New functions. (read_symlink): Create a new symlink stack entry. (traverse_next): Follow ".." components within the working directory. When hitting symlinks, "follow" them by reading and returning them. (traverse_another_path): Recursively traverse symlinks.
* Fix symlinks test case on some architecturesAndreas Gruenbacher2015-02-101-2/+3
| | | | | | | | | * src/safe.c: Include util.h for say(). Define EFTYPE if it isn't defined already. (traverse_another_path): When openat fails, also check for EMLINK, EFTYPE, and ENOTDIR. Change the error message to "file ... is not a directory" and only skip the rest of the patch instead of aborting. * tests/symlinks: Update.
* Check the result of the --follow-symlinks optionAndreas Gruenbacher2015-02-021-0/+8
| | | | | * tests/symlinks: Check the result of treating a symlink as a file with --follow-symlinks.
* test-lib.sh: factorize require_* functionsQuentin Casasnovas2015-01-311-1/+1
| | | | | | | Since the code is identical when just checking if a utility is present on the system or not, we can factorize it. Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
* Add test case for patch behind symlinkAndreas Gruenbacher2015-01-311-0/+17
| | | | | * tests/symlinks: Add a test case where the patch file itself is in a path that follows a symbolic link; we want to continue allowing that.
* Allow arbitrary symlink targets againTim Waugh2015-01-311-18/+39
| | | | | | * src/util.c (symlink_target_is_valid): Remove. (move_file): Remove symlink target checking. * tests/symlinks: Update test case.
* Fix the fix for CVE-2015-1196v2.7.3Andreas Gruenbacher2015-01-221-14/+18
| | | | | | | | | * src/util.c (filename_is_safe): New function split off from name_is_valid(). (symlink_target_is_valid): Explain why we cannot have absolute symlinks or symlinks with ".." components for now. (move_file): Move absolute filename check here and explain. * tests/symlinks: Put test case with ".." symlink in comments for now. * NEWS: Add CVE number.
* Make sure symlinks don't point outside working directory (CVE-2015-119)Andreas Gruenbacher2015-01-191-0/+53
| | | | | | | | | | | When creating symlinks from git-style patches, make sure the symlinks don't point above the current working directory. Otherwise, a subsequent patch could use the symlink to write outside the working directory. * src/pch.c (symlink_target_is_valid): New function to check for valid symlink targets. * src/util.c (move_file): Use symlink_target_is_valid() here. * tests/symlinks: Add valid and invalid symlink test cases.
* Add --follow-symlinks option for backwards compatibilityAndreas Gruenbacher2012-09-191-0/+5
| | | | | | | | | * src/common.h (follow_symlinks): New variable. * src/patch.c (longopts): Add new --follow-symlinks option. (get_some_switches): Recognize the new option. * src/util.c (stat_file): Follow symlinks if requested. * patch.man: Document the new option. * tests/symlinks: Add test case.
* Improve error message when patching a file of different typeAndreas Gruenbacher2012-09-181-3/+3
| | | | | | * src/inp.c (get_input_file): Improve error message when patching a file of different type. * tests/symlinks: Update test case.
* Minor test case updatesAndreas Gruenbacher2012-09-181-4/+4
| | | | | * tests/dash-o-append: Minor update (still expected to fail). * tests/symlinks: Minor update.
* Remove invalid symlink test caseAndreas Gruenbacher2012-04-171-21/+0
| | | | | | * tests/symlinks: Remove test case which deletes and then recreates a symlink: all patches in a git-style input file must refer to the "before" state; the test case is invalid.
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* maint: update copyright date year ranges to include 2011Jim Meyering2011-03-271-1/+1
| | | | | * bootstrap.conf (gnulib_modules): Add update-copyright. Run "make update-copyright".
* maint: avoid non-portable use of test -aJim Meyering2011-03-261-1/+1
| | | | | | | | | | With these changes, "make sc_prohibit_test_minus_ao" almost passes. Uses of "test -o" remain. Note: unchecked uses of test -ot/-nt also remain. * tests/empty-files: Use "test C1 && test C2", not "test C1 -a C2" * tests/merge: Likewise. * tests/symlinks: Likewise. * tests/test-lib.sh: Likewise.
* Fix backup file detection for deleted filesAndreas Gruenbacher2010-05-041-0/+21
| | | | | | | | | | * src/util.c (create_backup): Document patch's backup file logic. (create_backup, create_backup_copy): Add a flag to remember the backup file; use when a patch deletes a file. (move_file, copy_file): Better error messages. * tests/Makefile.am (TESTS): Remove remember-backup-files-2. * tests/remember-backup-files: Add tests from remember-backup-files-2. * tests/symlinks: Add a symlink backup file test.
* Improve the symlink backup file testsAndreas Gruenbacher2010-05-031-2/+2
| | | | * tests/symlinks: Improve the backup file tests.
* git diffs: Support symlinksAndreas Gruenbacher2010-05-021-1/+103
| | | | | * src/patch.c (main): Support git symlink diffs. * tests/symlinks: Add git symlink diff test cases.
* Refuse to patch symlinksAndreas Gruenbacher2010-04-271-0/+76
* src/inp.c (get_input_file), src/pch.c (there_is_another_patch, intuit_diff_type): Use lstat instead of stat. This causes patch to refuse patching symlinks (get_input_file() will refuse to read them). * src/util.c (create_backup): Refuse to create backups of symlinks. * tests/symlinks: New test case. * tests/Makefile.am (TESTS): Add test case. * bootstrap.conf: Use the gnulib lstat module.