diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2021-01-29 16:34:27 +0000 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2021-01-29 18:26:57 +0000 |
commit | 0c70e694cf1a703798c0778a3236079e1b25c91d (patch) | |
tree | c376d4e1f4cabb268f5b87f4dc75c5040e2c2efb /src | |
parent | 37a81ae7317bb78b2ff152821930c2ff0873512b (diff) |
Lookups: fix $local_part_data for a match on a filename list element. Bug 2691
Diffstat (limited to 'src')
-rw-r--r-- | src/src/match.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/src/match.c b/src/src/match.c index 597b633fe..73cdab012 100644 --- a/src/src/match.c +++ b/src/src/match.c @@ -809,19 +809,19 @@ while ((sss = string_nextinlist(&list, &sep, NULL, 0))) sss = ss + 1; } - ss = filebuffer + Ustrlen(filebuffer); /* trailing space */ + ss = filebuffer + Ustrlen(filebuffer); /* trailing space */ while (ss > filebuffer && isspace(ss[-1])) ss--; *ss = 0; ss = filebuffer; - while (isspace(*ss)) ss++; /* leading space */ + while (isspace(*ss)) ss++; /* leading space */ - if (*ss == 0) continue; /* ignore empty */ + if (!*ss) continue; /* ignore empty */ - file_yield = yield; /* positive yield */ - sss = ss; /* for debugging */ + file_yield = yield; /* positive yield */ + sss = ss; /* for debugging */ - if (*ss == '!') /* negation */ + if (*ss == '!') /* negation */ { file_yield = (file_yield == OK)? FAIL : OK; while (isspace((*(++ss)))); @@ -833,6 +833,11 @@ while ((sss = string_nextinlist(&list, &sep, NULL, 0))) (void)fclose(f); HDEBUG(D_lists) debug_printf("%s %s (matched \"%s\" in %s)\n", ot, yield == OK ? "yes" : "no", sss, filename); + + /* The "pattern" being matched came from the file; we use a stack-local. + Copy it to allocated memory now we know it matched. */ + + if (valueptr) *valueptr = string_copy(ss); return file_yield; case DEFER: |