diff --git a/builtin-mv.c b/builtin-mv.c
index a731f8d9cfed783fb59cb64db93f854ef0a4ebf9..e7b5eb7088dc3d45608a7d9b3ebaf1c66501596e 100644 (file)
--- a/builtin-mv.c
+++ b/builtin-mv.c
/* Checking */
for (i = 0; i < count; i++) {
+ int length;
const char *bad = NULL;
if (show_only)
}
if (!bad &&
- !strncmp(destination[i], source[i], strlen(source[i])))
+ (length = strlen(source[i])) >= 0 &&
+ !strncmp(destination[i], source[i], length) &&
+ (destination[i][length] == 0 || destination[i][length] == '/'))
bad = "can not move directory into itself";
if (!bad && cache_name_pos(source[i], strlen(source[i])) < 0)