diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-08-27 17:02:19 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-08-27 17:02:19 +0000 |
commit | 0f214ecef0a65fee01b12e2d75b80c398332b3ba (patch) | |
tree | 97069581e6b59530ebaf6e03cb550984661eaff5 | |
parent | 8a5fab6333eee874e0675a89937d31b9ae3a7345 (diff) | |
download | busybox-w32-0f214ecef0a65fee01b12e2d75b80c398332b3ba.tar.gz busybox-w32-0f214ecef0a65fee01b12e2d75b80c398332b3ba.tar.bz2 busybox-w32-0f214ecef0a65fee01b12e2d75b80c398332b3ba.zip |
cp: fix recursion check to not waste bytes remembering names of dirs
-rw-r--r-- | libbb/copy_file.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index b70d7b5e0..efb969faa 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
@@ -114,7 +114,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
114 | 114 | ||
115 | if (S_ISDIR(source_stat.st_mode)) { | 115 | if (S_ISDIR(source_stat.st_mode)) { |
116 | DIR *dp; | 116 | DIR *dp; |
117 | const char *existing_name; | 117 | const char *tp; |
118 | struct dirent *d; | 118 | struct dirent *d; |
119 | mode_t saved_umask = 0; | 119 | mode_t saved_umask = 0; |
120 | 120 | ||
@@ -124,11 +124,11 @@ int copy_file(const char *source, const char *dest, int flags) | |||
124 | } | 124 | } |
125 | 125 | ||
126 | /* Did we ever create source ourself before? */ | 126 | /* Did we ever create source ourself before? */ |
127 | existing_name = is_in_ino_dev_hashtable(&source_stat); | 127 | tp = is_in_ino_dev_hashtable(&source_stat); |
128 | if (existing_name) { | 128 | if (tp) { |
129 | /* We did! it's a recursion! man the lifeboats... */ | 129 | /* We did! it's a recursion! man the lifeboats... */ |
130 | bb_error_msg("recursion detected, omitting directory '%s'", | 130 | bb_error_msg("recursion detected, omitting directory '%s'", |
131 | existing_name); | 131 | source); |
132 | return -1; | 132 | return -1; |
133 | } | 133 | } |
134 | 134 | ||
@@ -222,8 +222,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
222 | int dst_fd; | 222 | int dst_fd; |
223 | 223 | ||
224 | if (ENABLE_FEATURE_PRESERVE_HARDLINKS && !FLAGS_DEREF) { | 224 | if (ENABLE_FEATURE_PRESERVE_HARDLINKS && !FLAGS_DEREF) { |
225 | char *link_target; | 225 | const char *link_target; |
226 | |||
227 | link_target = is_in_ino_dev_hashtable(&source_stat); | 226 | link_target = is_in_ino_dev_hashtable(&source_stat); |
228 | if (link_target) { | 227 | if (link_target) { |
229 | if (link(link_target, dest) < 0) { | 228 | if (link(link_target, dest) < 0) { |