]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cp,mv,install: avoid opening non directory destination
authorPádraig Brady <P@draigBrady.com>
Sat, 9 Apr 2022 14:46:52 +0000 (15:46 +0100)
committerPádraig Brady <P@draigBrady.com>
Sat, 9 Apr 2022 21:21:24 +0000 (22:21 +0100)
commitcc01b8a8f43bd1e02339322595f7a20e72a8c155
treeef417e854cc0bbc4002012ee01cefec13952e048
parent54bec51754c963562378c85b0e1561b84c326785
cp,mv,install: avoid opening non directory destination

commit v9.0-66-ge2daa8f79 introduced an issue, for example
where cp could hang when overwriting a destination fifo,
when it would try to open() the fifo on systems
like Solaris 10 that didn't support the O_DIRECTORY flag.

This is still racy on such systems, but only in the
case where a directory is replaced by a fifo in
the small window between stat() and open().

* src/system.h (target_directory_operand): On systems without
O_DIRECTORY, ensure the file is a directory before attempting to open().
* tests/cp/special-f.sh: Protect cp with timeout(1),
as cp was seen to hang when trying to overwrite an existing fifo.
* NEWS: Mention the bug fix.
NEWS
src/system.h
tests/cp/special-f.sh