mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-30 05:01:39 +01:00
cp -p could report success even if a file copy failed. This was due to
the cumulative exit status being overwritten when directory permissions were being set. This was particularly bad when called from mv(1) to perform a cross-device move as the original files were deleted even if the copy failed. Reported by: Slaven Rezic <slaven.rezic@berlin.de> Patch by: bde PR: 42789
This commit is contained in:
parent
a0c6726472
commit
eedc99e7b5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103801
@ -361,9 +361,10 @@ copy(char *argv[], enum op type, int fts_options)
|
||||
* honour setuid, setgid and sticky bits, but we
|
||||
* normally want to preserve them on directories.
|
||||
*/
|
||||
if (pflag)
|
||||
rval = setfile(curr->fts_statp, 0);
|
||||
else {
|
||||
if (pflag) {
|
||||
if (setfile(curr->fts_statp, 0))
|
||||
rval = 1;
|
||||
} else {
|
||||
mode = curr->fts_statp->st_mode;
|
||||
if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) ||
|
||||
((mode | S_IRWXU) & mask) != (mode & mask))
|
||||
|
Loading…
Reference in New Issue
Block a user