diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2019-05-28 20:53:53 +0100 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2019-05-28 20:53:53 +0100 |
commit | 4b85edface379a3575273a2b712d80bd9420d4c9 (patch) | |
tree | 0c5a54c9348554428536898827fab71111e6634e | |
parent | 3eea35d0853bddae13fa6f122669935a01618bf9 (diff) | |
download | zsh-4b85edface379a3575273a2b712d80bd9420d4c9.tar.gz zsh-4b85edface379a3575273a2b712d80bd9420d4c9.tar.xz zsh-4b85edface379a3575273a2b712d80bd9420d4c9.zip |
44361: Initialise variables in pattern matching.
These are used recursively and it's a bit obscure if there are case where the value can leak.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/pattern.c | 22 |
2 files changed, 17 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog index d05a624d2..1f386c05e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-05-28 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 44361: Src/pattern.c: Ensure variables used recursively are + initialised in pattern matching. + 2019-05-28 Peter Stephenson <p.stephenson@samsung.com> * Jim Murphy: 44364: Doc/Zsh/intro.yo: refer to main zsh page in diff --git a/Src/pattern.c b/Src/pattern.c index 737f5cdcb..97d488a31 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -2030,6 +2030,16 @@ int errsfound; /* Total error count so far */ /**/ int forceerrs; /* Forced maximum error count */ +/* + * exactpos is used to remember how far down an exact string we have + * matched, if we are doing approximation and can therefore redo from + * the same point; we never need to otherwise. + * + * exactend is a pointer to the end of the string, which isn't + * null-terminated. + */ +static char *exactpos, *exactend; + /**/ void pattrystart(void) @@ -2463,6 +2473,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, patinput = patinstart; + exactpos = exactend = NULL; + /* The only external call to patmatch --- all others are recursive */ if (patmatch((Upat)progstr)) { /* * we were lazy and didn't save the globflags if an exclusion @@ -2653,16 +2665,6 @@ patmatchlen(void) (charmatch_cache = (expr), CHARMATCH(charmatch_cache, chpa)) /* - * exactpos is used to remember how far down an exact string we have - * matched, if we are doing approximation and can therefore redo from - * the same point; we never need to otherwise. - * - * exactend is a pointer to the end of the string, which isn't - * null-terminated. - */ -static char *exactpos, *exactend; - -/* * Main matching routine. * * Testing the tail end of a match is usually done by recursion, but |