Fixed a bug where an exclude name that got sent over the wire could get
authorWayne Davison <wayned@samba.org>
Sat, 10 Apr 2004 10:31:11 +0000 (10:31 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 10 Apr 2004 10:31:11 +0000 (10:31 +0000)
an extra "- " or "+ " parsed off the start of the name (i.e. we have to
quote excluded names that start with those strings with an extra "- "
at the start).

exclude.c

index e0c8bed..1003f6a 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -328,32 +328,34 @@ void send_exclude_list(int f)
                add_exclude(&exclude_list, "/*/*", ADD_EXCLUDE);
 
        if (!exclude_list) {
-               write_int(f,0);
+               write_int(f, 0);
                return;
        }
 
        for (i = 0; exclude_list[i]; i++) {
                unsigned int l;
-               char pattern[MAXPATHLEN+1];
+               char p[MAXPATHLEN+1];
 
-               l = strlcpy(pattern, exclude_list[i]->pattern, sizeof pattern);
+               l = strlcpy(p, exclude_list[i]->pattern, sizeof p);
                if (l == 0 || l >= MAXPATHLEN)
                        continue;
                if (exclude_list[i]->directory) {
-                       pattern[l++] = '/';
-                       pattern[l] = '\0';
+                       p[l++] = '/';
+                       p[l] = '\0';
                }
 
                if (exclude_list[i]->include) {
-                       write_int(f,l+2);
-                       write_buf(f,"+ ",2);
-               } else {
-                       write_int(f,l);
-               }
-               write_buf(f,pattern,l);
+                       write_int(f, l + 2);
+                       write_buf(f, "+ ", 2);
+               } else if ((*p == '-' || *p == '+') && p[1] == ' ') {
+                       write_int(f, l + 2);
+                       write_buf(f, "- ", 2);
+               } else
+                       write_int(f, l);
+               write_buf(f, p, l);
        }
 
-       write_int(f,0);
+       write_int(f, 0);
 }
 
 
@@ -446,7 +448,7 @@ void add_cvs_excludes(void)
        char *p;
        int i;
 
-       for (i=0; cvs_ignore_list[i]; i++)
+       for (i = 0; cvs_ignore_list[i]; i++)
                add_exclude(&exclude_list, cvs_ignore_list[i], ADD_EXCLUDE);
 
        if ((p = getenv("HOME"))