From 71b98e52d885946bb67383080e10499f3d09bb32 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 17 Oct 2023 20:27:56 +0300 Subject: [PATCH] Fixed recursion in cp --- coreutils/cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreutils/cp.c b/coreutils/cp.c index aff13d5..428eaee 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -99,7 +99,7 @@ int cptree(const char *src, const char *dst) { struct dirent *ep; while ((ep = readdir(dir)) != NULL) { - if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, "..")) + if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, "..") || !strcmp(dst, ep->d_name)) continue; char *src_path = make_path(src, ep->d_name);