logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 4e06af59440ab1a824dd87ff8669bda47aae9571
parent faade53d0382ee2dfef54d2eeec6cc0ffa181388
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 23 Apr 2025 20:10:48 +0200

cmd/mv: handle errors from child_destdir.fd = openat(…)

Found via clang scan-build.

Diffstat:

Mcmd/mv.c11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/cmd/mv.c b/cmd/mv.c @@ -297,6 +297,17 @@ do_renameat(struct named_fd srcdir, .sep = "/", }; + if(child_destdir.fd < 0) + { + fprintf(stderr, + "mv: error: Failed opening destination directory '%s%s%s': %s\n", + destdir.name, + destdir.sep, + dest, + strerror(errno)); + return -1; + } + if(rename_dir_entries(child_srcdir, child_destdir) < 0) return -1; close(child_srcdir.fd);