Fix sending of "." attributes for implied-dot-dir.
authorWayne Davison <wayned@samba.org>
Sat, 27 Aug 2011 18:56:57 +0000 (11:56 -0700)
committerWayne Davison <wayned@samba.org>
Sat, 27 Aug 2011 19:08:19 +0000 (12:08 -0700)
flist.c

diff --git a/flist.c b/flist.c
index 9e5bdd0..cbd837c 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -2102,12 +2102,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                                fn = fbuf;
                        /* A leading ./ can be used in relative mode to affect
                         * the dest dir without its name being in the path. */
                                fn = fbuf;
                        /* A leading ./ can be used in relative mode to affect
                         * the dest dir without its name being in the path. */
-                       if (*fn == '.' && fn[1] == '/' && !implied_dot_dir) {
-                               send_file_name(f, flist, ".", NULL,
-                                   (flags | FLAG_IMPLIED_DIR) & ~FLAG_CONTENT_DIR,
-                                   ALL_FILTERS);
-                               implied_dot_dir = 1;
-                       }
+                       if (*fn == '.' && fn[1] == '/' && fn[2] && !implied_dot_dir)
+                               implied_dot_dir = -1;
                        len = clean_fname(fn, CFN_KEEP_TRAILING_SLASH
                                            | CFN_DROP_TRAILING_DOT_DIR);
                        if (len == 1) {
                        len = clean_fname(fn, CFN_KEEP_TRAILING_SLASH
                                            | CFN_DROP_TRAILING_DOT_DIR);
                        if (len == 1) {
@@ -2145,11 +2141,20 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                dirlen = dir ? strlen(dir) : 0;
                if (dirlen != lastdir_len || memcmp(lastdir, dir, dirlen) != 0) {
                        if (!change_pathname(NULL, dir, -dirlen))
                dirlen = dir ? strlen(dir) : 0;
                if (dirlen != lastdir_len || memcmp(lastdir, dir, dirlen) != 0) {
                        if (!change_pathname(NULL, dir, -dirlen))
-                               continue;
+                               goto bad_path;
                        lastdir = pathname;
                        lastdir_len = pathname_len;
                        lastdir = pathname;
                        lastdir_len = pathname_len;
-               } else if (!change_pathname(NULL, lastdir, lastdir_len))
+               } else if (!change_pathname(NULL, lastdir, lastdir_len)) {
+                   bad_path:
+                       if (implied_dot_dir < 0)
+                               implied_dot_dir = 0;
                        continue;
                        continue;
+               }
+
+               if (implied_dot_dir < 0) {
+                       send_file_name(f, flist, ".", NULL, (flags | FLAG_IMPLIED_DIR) & ~FLAG_CONTENT_DIR, ALL_FILTERS);
+                       implied_dot_dir = 1;
+               }
 
                if (fn != fbuf)
                        memmove(fbuf, fn, len + 1);
 
                if (fn != fbuf)
                        memmove(fbuf, fn, len + 1);