Commit Graph

15 Commits

Author SHA1 Message Date
Jean Delvare c3fb4c48e5 Don't leak temporary file on failed multi-file ed-style patch
The previous fix worked fine with single-file ed-style patches, but
would still leak temporary files in the case of multi-file ed-style
patch. Fix that case as well, and extend the test case to check for
it.

* src/patch.c (main): Unlink TMPEDNAME if needed before moving to
  the next file in a patch.

This closes bug #53820:
https://savannah.gnu.org/bugs/index.php?53820

Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)")
Fixes: 19599883ffb6 ("Don't leak temporary file on failed ed-style patch")

Gbp-Pq: Name 0007-Do_not_leak_temporary_file_on_failed_multi-file.patch
2022-05-14 02:38:25 +08:00
Jean Delvare 5ee73250df Don't leak temporary file on failed ed-style patch
Now that we write ed-style patches to a temporary file before we
apply them, we need to ensure that the temporary file is removed
before we leave, even on fatal error.

* src/pch.c (do_ed_script): Use global TMPEDNAME instead of local
  tmpname. Don't unlink the file directly, instead tag it for removal
  at exit time.
* src/patch.c (cleanup): Unlink TMPEDNAME at exit.

This closes bug #53820:
https://savannah.gnu.org/bugs/index.php?53820

Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)")

Gbp-Pq: Name 0006-Do_not_leak_temporary_file.patch
2022-05-14 02:38:25 +08:00
Andreas Gruenbacher 6e5f3d2032 Invoke ed directly instead of using the shell
* src/pch.c (do_ed_script): Invoke ed directly instead of using a shell
command to avoid quoting vulnerabilities.

Gbp-Pq: Name 0005-CVE-2019-13638.patch
2022-05-14 02:38:25 +08:00
Andreas Gruenbacher a1508e0da9 Don't follow symlinks unless --follow-symlinks is given
* src/inp.c (plan_a, plan_b), src/util.c (copy_to_fd, copy_file,
append_to_file): Unless the --follow-symlinks option is given, open files with
the O_NOFOLLOW flag to avoid following symlinks.  So far, we were only doing
that consistently for input files.
* src/util.c (create_backup): When creating empty backup files, (re)create them
with O_CREAT | O_EXCL to avoid following symlinks in that case as well.

Gbp-Pq: Name 0004-CVE-2019-13636.patch
2022-05-14 02:38:25 +08:00
Andreas Gruenbacher fb5eb7caeb Don't crash when RLIMIT_NOFILE is set to RLIM_INFINITY
* src/safe.c (min_cached_fds): Define minimum number of cached dir file
descriptors.
(max_cached_fds): Change type to rlim_t to allow storing RLIM_INFINITY.
(init_dirfd_cache): Set max_cached_fds to RLIM_INFINITY when RLIMIT_NOFILE is
RLIM_INFINITY.  Set the initial hash table size to min_cached_fds, independent
of RLIMIT_NOFILE: patches commonly only affect one or a few files, so a small
hash table will usually suffice; if needed, the hash table will grow.
(insert_cached_dirfd): Don't shrink the cache when max_cached_fds is
RLIM_INFINITY.

Gbp-Pq: Name 0003-Do_not_crash_when_RLIMIT_NOFILE_is_set_to_RLIM_INFINITY.patch
2022-05-14 02:38:25 +08:00
Andreas Gruenbacher 9291b60b68 Abort when cleaning up fails
When a fatal error triggers during cleanup, another attempt will be made to
clean up, which will likely lead to the same fatal error.  So instead, bail out
when that happens.
src/patch.c (cleanup): Bail out when called recursively.
(main): There is no need to call output_files() before cleanup() as cleanup()
already does that.

Gbp-Pq: Name 0002-Abort_when_cleaning_up_fails.patch
2022-05-14 02:38:25 +08:00
Bruno Haible 566c627d53 [PATCH] Fix 'ed-style' test failure.
* tests/ed-style: Remove '?' line from expected output.

Gbp-Pq: Name 0001-Fix-ed-style-test-failure.patch
2022-05-14 02:38:25 +08:00
Andreas Gruenbacher 9c4853863a Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)
* src/pch.c (do_ed_script): Write ed script to a temporary file instead
of piping it to ed: this will cause ed to abort on invalid commands
instead of rejecting them and carrying on.
* tests/ed-style: New test case.
* tests/Makefile.am (TESTS): Add test case.

Gbp-Pq: Name Fix_arbitrary_command_execution_in_ed-style_patches.patch
2022-05-14 02:38:25 +08:00
Andreas Gruenbacher efcc1c0404 Allow input files to be missing for ed-style patches
* src/pch.c (do_ed_script): Allow input files to be missing so that new
files will be created as with non-ed-style patches.

Gbp-Pq: Name Allow_input_files_to_be_missing_for_ed-style_patches.patch
2022-05-14 02:38:25 +08:00
Andreas Gruenbacher a9d3ef5a4c Fix segfault with mangled rename patch
http://savannah.gnu.org/bugs/?53132
* src/pch.c (intuit_diff_type): Ensure that two filenames are specified
for renames and copies (fix the existing check).

Gbp-Pq: Name Fix_segfault_with_mangled_rename_patch.patch
2022-05-14 02:38:25 +08:00
Laszlo Boszormenyi (GCS) 4368f4942c m-merge
Gbp-Pq: Name m-merge
2022-05-14 02:38:24 +08:00
Laszlo Boszormenyi (GCS) bd46c9832c backupmode
Gbp-Pq: Name 558485-backupmode
2022-05-14 02:38:24 +08:00
Laszlo Boszormenyi (GCS) 760573342c path_max
Gbp-Pq: Name path_max
2022-05-14 02:38:24 +08:00
openKylinBot 06beef842c Import Debian changes 2.7.6-ok1
patch (2.7.6-ok1) yangtze; urgency=high

  * Build for openKylin.
2022-05-14 02:38:20 +08:00
openKylinBot 9c1d3c7169 Import Upstream version 2.7.6 2022-05-14 02:38:20 +08:00