001-CVE-2017-7186 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #CVE-2017-7186 patch
  2. --- trunk/pcre_internal.h 2016/05/21 13:34:44 1649
  3. +++ trunk/pcre_internal.h 2017/02/24 17:30:30 1688
  4. @@ -2772,6 +2772,9 @@
  5. extern const pcre_uint16 PRIV(ucd_stage2)[];
  6. extern const pcre_uint32 PRIV(ucp_gentype)[];
  7. extern const pcre_uint32 PRIV(ucp_gbtable)[];
  8. +#ifdef COMPILE_PCRE32
  9. +extern const ucd_record PRIV(dummy_ucd_record)[];
  10. +#endif
  11. #ifdef SUPPORT_JIT
  12. extern const int PRIV(ucp_typerange)[];
  13. #endif
  14. @@ -2780,9 +2783,15 @@
  15. /* UCD access macros */
  16. #define UCD_BLOCK_SIZE 128
  17. -#define GET_UCD(ch) (PRIV(ucd_records) + \
  18. +#define REAL_GET_UCD(ch) (PRIV(ucd_records) + \
  19. PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \
  20. UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])
  21. +
  22. +#ifdef COMPILE_PCRE32
  23. +#define GET_UCD(ch) ((ch > 0x10ffff)? PRIV(dummy_ucd_record) : REAL_GET_UCD(ch))
  24. +#else
  25. +#define GET_UCD(ch) REAL_GET_UCD(ch)
  26. +#endif
  27. #define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype
  28. #define UCD_SCRIPT(ch) GET_UCD(ch)->script
  29. --- trunk/pcre_ucd.c 2014/06/19 07:51:39 1490
  30. +++ trunk/pcre_ucd.c 2017/02/24 17:30:30 1688
  31. @@ -38,6 +38,20 @@
  32. const pcre_uint32 PRIV(ucd_caseless_sets)[] = {0};
  33. #else
  34. +/* If the 32-bit library is run in non-32-bit mode, character values
  35. +greater than 0x10ffff may be encountered. For these we set up a
  36. +special record. */
  37. +
  38. +#ifdef COMPILE_PCRE32
  39. +const ucd_record PRIV(dummy_ucd_record)[] = {{
  40. + ucp_Common, /* script */
  41. + ucp_Cn, /* type unassigned */
  42. + ucp_gbOther, /* grapheme break property */
  43. + 0, /* case set */
  44. + 0, /* other case */
  45. + }};
  46. +#endif
  47. +
  48. /* When recompiling tables with a new Unicode version, please check the
  49. types in this structure definition from pcre_internal.h (the actual
  50. field names will be different):