/[pcre]/code/trunk/pcre_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1059 by chpe, Tue Oct 16 15:53:53 2012 UTC revision 1060 by chpe, Tue Oct 16 15:53:57 2012 UTC
# Line 776  check_escape(const pcre_uchar **ptrptr, Line 776  check_escape(const pcre_uchar **ptrptr,
776  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
777  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
778  const pcre_uchar *ptr = *ptrptr + 1;  const pcre_uchar *ptr = *ptrptr + 1;
779  pcre_int32 c;  pcre_uint32 c;
780  int escape = 0;  int escape = 0;
781  int i;  int i;
782    
# Line 832  else Line 832  else
832          c = 0;          c = 0;
833          for (i = 0; i < 4; ++i)          for (i = 0; i < 4; ++i)
834            {            {
835            register int cc = *(++ptr);            register pcre_uint32 cc = *(++ptr);
836  #ifndef EBCDIC  /* ASCII/UTF-8 coding */  #ifndef EBCDIC  /* ASCII/UTF-8 coding */
837            if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */            if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */
838            c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));            c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
# Line 1042  else Line 1042  else
1042          c = 0;          c = 0;
1043          for (i = 0; i < 2; ++i)          for (i = 0; i < 2; ++i)
1044            {            {
1045            register int cc = *(++ptr);            register pcre_uint32 cc = *(++ptr);
1046  #ifndef EBCDIC  /* ASCII/UTF-8 coding */  #ifndef EBCDIC  /* ASCII/UTF-8 coding */
1047            if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */            if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */
1048            c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));            c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
# Line 1058  else Line 1058  else
1058      if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)      if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
1059        {        {
1060        const pcre_uchar *pt = ptr + 2;        const pcre_uchar *pt = ptr + 2;
1061          BOOL overflow;
1062    
1063        c = 0;        c = 0;
1064          overflow = FALSE;
1065        while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0)        while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0)
1066          {          {
1067          register int cc = *pt++;          register pcre_uint32 cc = *pt++;
1068          if (c == 0 && cc == CHAR_0) continue;     /* Leading zeroes */          if (c == 0 && cc == CHAR_0) continue;     /* Leading zeroes */
1069    
1070    #ifdef COMPILE_PCRE32
1071            if (c >= 0x10000000l) { overflow = TRUE; break; }
1072    #endif
1073    
1074  #ifndef EBCDIC  /* ASCII/UTF-8 coding */  #ifndef EBCDIC  /* ASCII/UTF-8 coding */
1075          if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */          if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */
1076          c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));          c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
# Line 1074  else Line 1080  else
1080  #endif  #endif
1081    
1082  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
1083          if (c > (utf ? 0x10ffff : 0xff)) { c = -1; break; }          if (c > (utf ? 0x10ffff : 0xff)) { overflow = TRUE; break; }
1084  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
1085          if (c > (utf ? 0x10ffff : 0xffff)) { c = -1; break; }          if (c > (utf ? 0x10ffff : 0xffff)) { overflow = TRUE; break; }
1086  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
1087          if (utf && c > 0x10ffff) { c = -1; break; }          if (utf && c > 0x10ffff) { overflow = TRUE; break; }
1088  #endif  #endif
1089          }          }
1090    
1091        if (c < 0)        if (overflow)
1092          {          {
1093          while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0) pt++;          while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0) pt++;
1094          *errorcodeptr = ERR34;          *errorcodeptr = ERR34;
# Line 1104  else Line 1110  else
1110      c = 0;      c = 0;
1111      while (i++ < 2 && MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0)      while (i++ < 2 && MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0)
1112        {        {
1113        int cc;                                  /* Some compilers don't like */        pcre_uint32 cc;                          /* Some compilers don't like */
1114        cc = *(++ptr);                           /* ++ in initializers */        cc = *(++ptr);                           /* ++ in initializers */
1115  #ifndef EBCDIC  /* ASCII/UTF-8 coding */  #ifndef EBCDIC  /* ASCII/UTF-8 coding */
1116        if (cc >= CHAR_a) cc -= 32;              /* Convert to upper case */        if (cc >= CHAR_a) cc -= 32;              /* Convert to upper case */

Legend:
Removed from v.1059  
changed lines
  Added in v.1060

  ViewVC Help
Powered by ViewVC 1.1.5