[CVE-2019-13636] Don't follow symlinks unless --follow-symlinks is given
authorAndreas Gruenbacher <agruen@gnu.org>
Mon, 15 Jul 2019 14:21:48 +0000 (16:21 +0200)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 16 May 2022 06:58:20 +0000 (15:58 +0900)
commit080a1e4cf99b47ffd5386c34af685f7ffd0a4faa
tree2da66bb403bd941dc917679c13f23236024cbaf8
parent1266f2514cc053bf0b74f69d76b7348595af71ea
[CVE-2019-13636] 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.

Change-Id: Ic1ace0a9b9123cebd9e5a5f6c39bf69b85229fd9
src/inp.c
src/util.c