Re: [pcre-dev] 8.33-RC1 is available for testing

Góra strony
Delete this message
Autor: Petr Pisar
Data:  
Dla: pcre-dev
Temat: Re: [pcre-dev] 8.33-RC1 is available for testing
On Thu, May 02, 2013 at 04:21:49PM +0200, Petr Pisar wrote:
> On Wed, May 01, 2013 at 05:51:40PM +0100, ph10@??? wrote:
> > I have put a release candidate for the 8.33 release here:
> >
> This release is not good. Tests fail on 64-bit PowerPC (they pass on 32-bit
> PowerPC):
>
> /(*LIMIT_MATCH=3000)(a+)*zz/I
> Capturing subpattern count = 1
> -Match limit = 3000
> +Match limit = 0
> No options
> No first char
> Need char = 'z'
>

I think that's because pcre_fullinfo() dereferences the destination pointer
without respect to the size of the referenced type:

case PCRE_INFO_MATCHLIMIT:
if ((re->flags & PCRE_MLSET) == 0) return PCRE_ERROR_UNSET;
*((unsigned long int *)where) = re->limit_match;
break;

However the `where' is declared in pcretest as pcre_uint32 which is variadic
type:

#if UINT_MAX == 4294967295U
typedef unsigned int pcre_uint32;
typedef int pcre_int32;
#define PCRE_UINT32_MAX UINT_MAX
#define PCRE_INT32_MAX INT_MAX
#elif ULONG_MAX == 4294967295UL
typedef unsigned long int pcre_uint32;
typedef long int pcre_int32;
#define PCRE_UINT32_MAX ULONG_MAX
#define PCRE_INT32_MAX LONG_MAX
#else
#error Cannot determine a type for 32-bit integers
#endif

64-bit PowerPC is the first case where pcre_uint32 gets 4 bytes as `unsingned
int'. And because it's big-endian the assignement in pcre_fullinfo() will
store the data off 4 bytes.

The same problem can be seen at PCRE_INFO_RECURSIONLIMIT.

-- Petr