[pcre-dev] [Bug 632] pcre_compile has no way to give length …

Pàgina inicial
Delete this message
Autor: Sean Middleditch
Data:  
A: pcre-dev
Assumpte: [pcre-dev] [Bug 632] pcre_compile has no way to give length of source
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=632




--- Comment #4 from Sean Middleditch <elanthis@???> 2007-11-20 17:21:24 ---
Yeah, I've seen that while working on said patch.

Like you said, it's mostly just tedious.

I've noticed four general types of changes that need to be made:

(1) The *ptr == 0 has to be replaced with ptr == end.
(2) Results from GETCHARINC and friends are checked against 0, so this must be
modified to check against ptr == end instead.
(3) Some loops continuously look up the current character in a table, and check
the return against 0, so these also need a ptr != end check.
(4) Some parts of the code loop while *ptr == 'x' (where x is some character or
another), so these need to be replaced with while ptr != end && *ptr == 'x'.

The only part I'm not 100% sure about is the GETCHARINC series of the macros,
but I just haven't looked at the UTF8 versions of them yet.

Most of the functions just need to take a copy of the end pointer. I renamed
pcre_compile2 to pcre_compile3 which takes a length used to calculate the end
pointer, and made pcre_compile and pcre_compile2 call into pcre_compile3 and
call strlen to figure out the proper length to pass in.

Do any of the unit tests include tests that have incomplete expressions or
incomplete UTF8 characters that could cause the code to try to walk past the
end of the string, or do I need to add some tests for that?


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email