diff options
author | tjr <tjr@FreeBSD.org> | 2005-08-17 11:37:38 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2005-08-17 11:37:38 +0000 |
commit | 3e6c619383729f66dd7bc034caedb789840f2491 (patch) | |
tree | b90425a2dd26c95b1ddd5b09464eefae5424f821 | |
parent | 92f771be39b581d179dbc96ace4f4e459583f537 (diff) | |
download | FreeBSD-src-3e6c619383729f66dd7bc034caedb789840f2491.zip FreeBSD-src-3e6c619383729f66dd7bc034caedb789840f2491.tar.gz |
Fix a boundary condition error in slow() and fast() in multibyte locales:
we must allow the character beginning at "p" to be converted to a wide
character for the purposes of EOL processing and word-boundary matching.
-rw-r--r-- | lib/libc/regex/engine.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 35bcb5a..bb55da1 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -808,10 +808,11 @@ sopno stopst; for (;;) { /* next character */ lastc = c; - if (p == m->endp) + if (p == m->endp) { + clen = 0; c = OUT; - else - clen = XMBRTOWC(&c, p, stop - p, &m->mbs, BADCHAR); + } else + clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR); if (EQ(st, fresh)) coldp = p; @@ -849,7 +850,7 @@ sopno stopst; } /* are we done? */ - if (ISSET(st, stopst) || p == stop) + if (ISSET(st, stopst) || p == stop || clen > stop - p) break; /* NOTE BREAK OUT */ /* no, we must deal with this character */ @@ -917,7 +918,7 @@ sopno stopst; c = OUT; clen = 0; } else - clen = XMBRTOWC(&c, p, stop - p, &m->mbs, BADCHAR); + clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR); /* is there an EOL and/or BOL between lastc and c? */ flagch = '\0'; @@ -955,7 +956,7 @@ sopno stopst; /* are we done? */ if (ISSET(st, stopst)) matchp = p; - if (EQ(st, empty) || p == stop) + if (EQ(st, empty) || p == stop || clen > stop - p) break; /* NOTE BREAK OUT */ /* no, we must deal with this character */ |