From: Wayne Davison Date: Sat, 15 May 2004 19:31:13 +0000 (+0000) Subject: - Complain about an exclude that was too long and then dump it X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/619d21ffc99dca4afab4d422d610167ae05af0a4 - Complain about an exclude that was too long and then dump it (used to be silently truncated). - Include extra space in our exclude-reading buffers so that we can fit a 2-char prefix and a trailing slash and still handle a MAXPATHLEN name. --- diff --git a/exclude.c b/exclude.c index 01401c5c..b48d674d 100644 --- a/exclude.c +++ b/exclude.c @@ -316,7 +316,7 @@ void add_exclude_file(struct exclude_list_struct *listp, const char *fname, int xflags) { FILE *fp; - char line[MAXPATHLEN]; + char line[MAXPATHLEN+3]; /* Room for "x " prefix and trailing slash. */ char *eob = line + MAXPATHLEN - 1; int word_split = xflags & XFLG_WORD_SPLIT; @@ -340,7 +340,7 @@ void add_exclude_file(struct exclude_list_struct *listp, const char *fname, while (1) { char *s = line; - int ch; + int ch, overflow = 0; while (1) { if ((ch = getc(fp)) == EOF) { if (ferror(fp) && errno == EINTR) @@ -353,6 +353,12 @@ void add_exclude_file(struct exclude_list_struct *listp, const char *fname, break; if (s < eob) *s++ = ch; + else + overflow = 1; + } + if (overflow) { + rprintf(FERROR, "discarding over-long exclude: %s...\n", line); + s = line; } *s = '\0'; /* Skip an empty token and (when line parsing) comments. */ @@ -405,7 +411,7 @@ void send_exclude_list(int f) void recv_exclude_list(int f) { - char line[MAXPATHLEN+1]; /* Allows a trailing slash on a max-len dir */ + char line[MAXPATHLEN+3]; /* Room for "x " prefix and trailing slash. */ unsigned int l; while ((l = read_int(f)) != 0) {