Some improvements to the file-name cleaning code:
[rsync/rsync.git] / exclude.c
index 027ea7a..422a824 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -43,7 +43,7 @@ extern unsigned int module_dirlen;
 
 struct filter_list_struct filter_list = { 0, 0, "" };
 struct filter_list_struct cvs_filter_list = { 0, 0, " [global CVS]" };
-struct filter_list_struct server_filter_list = { 0, 0, " [daemon]" };
+struct filter_list_struct daemon_filter_list = { 0, 0, " [daemon]" };
 
 /* Need room enough for ":MODS " prefix plus some room to grow. */
 #define MAX_RULE_PREFIX (16)
@@ -295,7 +295,7 @@ static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
                        strlcpy(to, merge_file, *len_ptr + 1);
                        merge_file = to;
                }
-               if (!sanitize_path(fn, merge_file, r, dirbuf_depth)) {
+               if (!sanitize_path(fn, merge_file, r, dirbuf_depth, SP_DEFAULT)) {
                        rprintf(FERROR, "merge-file name overflows: %s\n",
                                merge_file);
                        return NULL;
@@ -517,13 +517,13 @@ void change_local_filter_dir(const char *dname, int dlen, int dir_depth)
        filt_array[cur_depth] = push_local_filters(dname, dlen);
 }
 
-static int rule_matches(char *fname, struct filter_struct *ex, int name_is_dir)
+static int rule_matches(const char *fname, struct filter_struct *ex, int name_is_dir)
 {
        int slash_handling, str_cnt = 0, anchored_match = 0;
        int ret_match = ex->match_flags & MATCHFLG_NEGATE ? 0 : 1;
        char *p, *pattern = ex->pattern;
        const char *strings[16]; /* more than enough */
-       char *name = fname + (*fname == '/');
+       const char *name = fname + (*fname == '/');
 
        if (!*name)
                return 0;
@@ -620,7 +620,7 @@ static void report_filter_result(char const *name,
  * Return -1 if file "name" is defined to be excluded by the specified
  * exclude list, 1 if it is included, and 0 if it was not matched.
  */
-int check_filter(struct filter_list_struct *listp, char *name, int name_is_dir)
+int check_filter(struct filter_list_struct *listp, const char *name, int name_is_dir)
 {
        struct filter_struct *ent;
 
@@ -1009,10 +1009,10 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
                return;
 
        if (*fname != '-' || fname[1] || am_server) {
-               if (server_filter_list.head) {
+               if (daemon_filter_list.head) {
                        strlcpy(line, fname, sizeof line);
                        clean_fname(line, CFN_COLLAPSE_DOT_DOT_DIRS);
-                       if (check_filter(&server_filter_list, line, 0) < 0)
+                       if (check_filter(&daemon_filter_list, line, 0) < 0)
                                fp = NULL;
                        else
                                fp = fopen(line, "rb");