From 43c893e73e461dd2df6fddbbd1808bb178adf833 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Mon, 14 Mar 2022 09:30:11 +0100 Subject: [PATCH] copy: fix wrong argument passed to S_ISREG() in copy_file_fd_full() Follow-up for 2f782044986a30bf73f1fe00209dbd204b3efe33. --- src/shared/copy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shared/copy.c b/src/shared/copy.c index 09417063562..cc76465fb1c 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -1214,7 +1214,10 @@ int copy_file_fd_full( if (r < 0) return r; - if (S_ISREG(fdt)) { + /* Make sure to copy file attributes only over if target is a regular + * file (so that copying a file to /dev/null won't alter the access + * mode/ownership of that device node...) */ + if (S_ISREG(st.st_mode)) { (void) copy_times(fdf, fdt, copy_flags); (void) copy_xattr(fdf, fdt, copy_flags); } -- 2.47.3