diff options
author | dcs <dcs@FreeBSD.org> | 2000-07-09 17:45:30 +0000 |
---|---|---|
committer | dcs <dcs@FreeBSD.org> | 2000-07-09 17:45:30 +0000 |
commit | 2f86797f52c5150ce19ceca600b6ed75ccf26577 (patch) | |
tree | 816cbb757a08cd0c562be6c07f2afad95673a20d /lib/libc | |
parent | 13a9107aac37e67e8ab42faaa4fd3b52bdb7c406 (diff) | |
download | FreeBSD-src-2f86797f52c5150ce19ceca600b6ed75ccf26577.zip FreeBSD-src-2f86797f52c5150ce19ceca600b6ed75ccf26577.tar.gz |
altoffset() always returned whenever it recursed, because at the end
of the processing of the recursion, "scan" would be pointing to O_CH
(or O_QUEST), which would then be interpreted as being the end character
for altoffset().
We avoid this by properly increasing scan before leaving the switch.
Without this, something like (a?b?)?cc would result in a g->moffset of
1 instead of 2.
I added a case to the soon-to-be-imported regex(3) test code to catch
this error.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/regex/regcomp.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index e0afdcc..bf92f2c 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -1891,6 +1891,10 @@ int mccs; OP(s) != OOR2) return -1; } while (OP(s) != O_QUEST && OP(s) != O_CH); + /* We must skip to the next position, or we'll + * leave altoffset() too early. + */ + scan++; break; case OANYOF: if (mccs) |