chiark / gitweb /
Commit Debian 3.0 (quilt) metadata
[pcre3.git] / debian / patches / upstream-fix-for-cve-2017-7186-upstream-
1 Description: Upstream fix for CVE-2017-7186 (Upstream rev 1688)
2  Fix Unicode property crash for 32-bit characters greater than 0x10ffff.
3 Author: Matthew Vernon <matthew@debian.org>
4 X-Dgit-Generated: 2:8.39-3 c4c2c7c4f74d53b263af2471d8e11db88096bd13
5
6 ---
7
8 --- pcre3-8.39.orig/pcre_internal.h
9 +++ pcre3-8.39/pcre_internal.h
10 @@ -2772,6 +2772,9 @@ extern const pcre_uint8  PRIV(ucd_stage1
11  extern const pcre_uint16 PRIV(ucd_stage2)[];
12  extern const pcre_uint32 PRIV(ucp_gentype)[];
13  extern const pcre_uint32 PRIV(ucp_gbtable)[];
14 +#ifdef COMPILE_PCRE32
15 +extern const ucd_record  PRIV(dummy_ucd_record)[];
16 +#endif
17  #ifdef SUPPORT_JIT
18  extern const int         PRIV(ucp_typerange)[];
19  #endif
20 @@ -2780,9 +2783,15 @@ extern const int         PRIV(ucp_typera
21  /* UCD access macros */
22  
23  #define UCD_BLOCK_SIZE 128
24 -#define GET_UCD(ch) (PRIV(ucd_records) + \
25 +#define REAL_GET_UCD(ch) (PRIV(ucd_records) + \
26          PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \
27          UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])
28 +        
29 +#ifdef COMPILE_PCRE32
30 +#define GET_UCD(ch) ((ch > 0x10ffff)? PRIV(dummy_ucd_record) : REAL_GET_UCD(ch))
31 +#else
32 +#define GET_UCD(ch) REAL_GET_UCD(ch)
33 +#endif 
34  
35  #define UCD_CHARTYPE(ch)    GET_UCD(ch)->chartype
36  #define UCD_SCRIPT(ch)      GET_UCD(ch)->script
37 --- pcre3-8.39.orig/pcre_ucd.c
38 +++ pcre3-8.39/pcre_ucd.c
39 @@ -38,6 +38,20 @@ const pcre_uint16 PRIV(ucd_stage2)[] = {
40  const pcre_uint32 PRIV(ucd_caseless_sets)[] = {0};
41  #else
42  
43 +/* If the 32-bit library is run in non-32-bit mode, character values
44 +greater than 0x10ffff may be encountered. For these we set up a
45 +special record. */
46 +
47 +#ifdef COMPILE_PCRE32
48 +const ucd_record PRIV(dummy_ucd_record)[] = {{
49 +  ucp_Common,    /* script */
50 +  ucp_Cn,        /* type unassigned */
51 +  ucp_gbOther,   /* grapheme break property */
52 +  0,             /* case set */
53 +  0,             /* other case */
54 +  }};
55 +#endif
56 +
57  /* When recompiling tables with a new Unicode version, please check the
58  types in this structure definition from pcre_internal.h (the actual
59  field names will be different):