aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPierre Pronchery <pierre@freebsdfoundation.org>2024-05-16 14:19:44 +0000
committerWarner Losh <imp@FreeBSD.org>2024-05-23 18:04:43 +0000
commit3d7c8f088796ec6ceb1d54005657dee78fd01fbe (patch)
treee614063adbd3bb7fc72abf00b92897adbcd78d37 /bin
parenta5f03413aade8f69cf954162151da043d34dd1f5 (diff)
Diffstat (limited to 'bin')
-rw-r--r--bin/cp/utils.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index d102fb076139..cfbb2022caaf 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -112,6 +112,8 @@ copy_file(const FTSENT *entp, int dne)
if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) < 0 ||
fstat(from_fd, &sb) != 0) {
warn("%s", entp->fts_path);
+ if (from_fd >= 0)
+ (void)close(from_fd);
return (1);
}
/*
@@ -124,6 +126,7 @@ copy_file(const FTSENT *entp, int dne)
*/
if ((sb.st_mode & S_IFMT) != (fs->st_mode & S_IFMT)) {
warnx("%s: File changed", entp->fts_path);
+ (void)close(from_fd);
return (1);
}
}