Moved the dir_count increment into an even better spot and make sure that
authorWayne Davison <wayned@samba.org>
Sun, 16 Dec 2007 22:14:35 +0000 (14:14 -0800)
committerWayne Davison <wayned@samba.org>
Sun, 16 Dec 2007 22:14:35 +0000 (14:14 -0800)
send_file_name() returned a non-NULL pointer before doing any DOT_NAME
processing in inc_recurse mode.

flist.c

diff --git a/flist.c b/flist.c
index cc7a873..69cfec1 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -389,6 +389,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
 
        /* Initialize starting value of xflags. */
        if (protocol_version >= 30 && S_ISDIR(file->mode)) {
 
        /* Initialize starting value of xflags. */
        if (protocol_version >= 30 && S_ISDIR(file->mode)) {
+               dir_count++;
                if (file->flags & FLAG_CONTENT_DIR)
                        xflags = file->flags & FLAG_TOP_DIR;
                else if (file->flags & FLAG_IMPLIED_DIR)
                if (file->flags & FLAG_CONTENT_DIR)
                        xflags = file->flags & FLAG_TOP_DIR;
                else if (file->flags & FLAG_IMPLIED_DIR)
@@ -1291,8 +1292,6 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
        flist_expand(flist, 1);
        flist->files[flist->used++] = file;
        if (f >= 0) {
        flist_expand(flist, 1);
        flist->files[flist->used++] = file;
        if (f >= 0) {
-               if (S_ISDIR(file->mode))
-                       dir_count++;
                send_file_entry(f, file, flist->used - 1, flist->ndx_start);
 #ifdef SUPPORT_ACLS
                if (preserve_acls && !S_ISLNK(file->mode)) {
                send_file_entry(f, file, flist->used - 1, flist->ndx_start);
 #ifdef SUPPORT_ACLS
                if (preserve_acls && !S_ISLNK(file->mode)) {
@@ -1975,7 +1974,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                        file = send_file_name(f, flist, fbuf, &st,
                                              top_flags, ALL_FILTERS);
                        if (inc_recurse) {
                        file = send_file_name(f, flist, fbuf, &st,
                                              top_flags, ALL_FILTERS);
                        if (inc_recurse) {
-                               if (name_type == DOT_NAME) {
+                               if (name_type == DOT_NAME && file) {
                                        if (send_dir_depth < 0) {
                                                send_dir_depth = 0;
                                                change_local_filter_dir(fbuf, len, send_dir_depth);
                                        if (send_dir_depth < 0) {
                                                send_dir_depth = 0;
                                                change_local_filter_dir(fbuf, len, send_dir_depth);