aboutsummaryrefslogtreecommitdiffstats
path: root/exclude.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2006-10-13 01:22:48 +0000
committerWayne Davison <wayned@samba.org>2006-10-13 01:22:48 +0000
commit969f7ed5b798d429236c8350e417b58172293a7f (patch)
treef6b2ac11739daf1d0fc5bd554906d7bdada40ce4 /exclude.c
parente825409a84c26bc1a0655a3eccaa6d947e59d788 (diff)
downloadandroid_external_rsync-969f7ed5b798d429236c8350e417b58172293a7f.tar.gz
android_external_rsync-969f7ed5b798d429236c8350e417b58172293a7f.tar.bz2
android_external_rsync-969f7ed5b798d429236c8350e417b58172293a7f.zip
Fixed an infinite loop in parse_rule() when a filter rule is too
longer for MAXPATHLEN. Also fixed a couple spots nearby that were erroneously treating pointer "cp" as a '\0'-terminated string.
Diffstat (limited to 'exclude.c')
-rw-r--r--exclude.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/exclude.c b/exclude.c
index 38bbd0cb..1541df77 100644
--- a/exclude.c
+++ b/exclude.c
@@ -906,12 +906,14 @@ void parse_rule(struct filter_list_struct *listp, const char *pattern,
&pat_len, &new_mflags);
if (!cp)
break;
+
+ pattern = cp + pat_len;
+
if (pat_len >= MAXPATHLEN) {
- rprintf(FERROR, "discarding over-long filter: %s\n",
- cp);
+ rprintf(FERROR, "discarding over-long filter: %.*s\n",
+ pat_len, cp);
continue;
}
- pattern = cp + pat_len;
if (new_mflags & MATCHFLG_CLEAR_LIST) {
if (verbose > 2) {
@@ -931,11 +933,9 @@ void parse_rule(struct filter_list_struct *listp, const char *pattern,
}
len = pat_len;
if (new_mflags & MATCHFLG_EXCLUDE_SELF) {
- const char *name = strrchr(cp, '/');
- if (name)
- len -= ++name - cp;
- else
- name = cp;
+ const char *name = cp + len;
+ while (name > cp && name[-1] != '/') name--;
+ len -= name - cp;
add_rule(listp, name, len, 0, 0);
new_mflags &= ~MATCHFLG_EXCLUDE_SELF;
len = pat_len;