Yocto 2.5

Move OpenBMC to Yocto 2.5(sumo)

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I5c5ad6904a16e14c1c397f0baf10c9d465594a78
diff --git a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/libpcre2-CVE-2017-7186.patch b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/libpcre2-CVE-2017-7186.patch
deleted file mode 100644
index bfa3bfe..0000000
--- a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/libpcre2-CVE-2017-7186.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-libpcre2-10.23: Fix CVE-2017-7186
-
-A fuzz on libpcre1 through the pcretest utility revealed an invalid read in the
-library. For who is interested in a detailed description of the bug, will
-follow a feedback from upstream:
-
-This was a genuine bug in the 32-bit library. Thanks for finding it. The crash
-was caused by trying to find a Unicode property for a code value greater than
-0x10ffff, the Unicode maximum, when running in non-UTF mode (where character
-values can be up to 0xffffffff).
-
-The complete ASan output:
-
-# pcretest -32 -d $FILE
-==14788==ERROR: AddressSanitizer: SEGV on unknown address 0x7f1bbffed4df (pc 0x7f1bbee3fe6b bp 0x7fff8b50d8c0 sp 0x7fff8b50d3a0 T0)
-==14788==The signal is caused by a READ memory access.
-    #0 0x7f1bbee3fe6a in match /tmp/portage/dev-libs/libpcre-8.40/work/pcre-8.40/pcre_exec.c:5473:18
-    #1 0x7f1bbee09226 in pcre32_exec /tmp/portage/dev-libs/libpcre-8.40/work/pcre-8.40/pcre_exec.c:6936:8
-    #2 0x527d6c in main /tmp/portage/dev-libs/libpcre-8.40/work/pcre-8.40/pcretest.c:5218:9
-    #3 0x7f1bbddd678f in __libc_start_main /tmp/portage/sys-libs/glibc-2.23-r3/work/glibc-2.23/csu/../csu/libc-start.c:289
-    #4 0x41b438 in _init (/usr/bin/pcretest+0x41b438)
-
-AddressSanitizer can not provide additional info.
-SUMMARY: AddressSanitizer: SEGV /tmp/portage/dev-libs/libpcre-8.40/work/pcre-8.40/pcre_exec.c:5473:18 in match
-==14788==ABORTING
-
-Upstream-Status: Backport [https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_ucd.c?view=patch&r1=316&r2=670&sortby=date \
-                        https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_internal.h?view=patch&r1=600&r2=670&sortby=date]
-CVE: CVE-2017-7186
-
-Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
-
---- trunk/src/pcre2_ucd.c  2015/07/17 15:44:51 316
-+++ trunk/src/pcre2_ucd.c  2017/02/24 18:25:32 670
-@@ -41,6 +41,20 @@
- 
- const char *PRIV(unicode_version) = "8.0.0";
- 
-+/* If the 32-bit library is run in non-32-bit mode, character values
-+greater than 0x10ffff may be encountered. For these we set up a
-+special record. */
-+
-+#if PCRE2_CODE_UNIT_WIDTH == 32
-+const ucd_record PRIV(dummy_ucd_record)[] = {{
-+  ucp_Common,    /* script */
-+  ucp_Cn,        /* type unassigned */
-+  ucp_gbOther,   /* grapheme break property */
-+  0,             /* case set */
-+  0,             /* other case */
-+  }};
-+#endif
-+
- /* When recompiling tables with a new Unicode version, please check the
- types in this structure definition from pcre2_internal.h (the actual
- field names will be different):
---- trunk/src/pcre2_internal.h 2016/11/19 12:46:24 600
-+++ trunk/src/pcre2_internal.h 2017/02/24 18:25:32 670
-@@ -1774,10 +1774,17 @@
- /* UCD access macros */
- 
- #define UCD_BLOCK_SIZE 128
--#define GET_UCD(ch) (PRIV(ucd_records) + \
-+#define REAL_GET_UCD(ch) (PRIV(ucd_records) + \
-         PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \
-         UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])
- 
-+#if PCRE2_CODE_UNIT_WIDTH == 32
-+#define GET_UCD(ch) ((ch > MAX_UTF_CODE_POINT)? \
-+  PRIV(dummy_ucd_record) : REAL_GET_UCD(ch))
-+#else
-+#define GET_UCD(ch) REAL_GET_UCD(ch)
-+#endif
-+
- #define UCD_CHARTYPE(ch)    GET_UCD(ch)->chartype
- #define UCD_SCRIPT(ch)      GET_UCD(ch)->script
- #define UCD_CATEGORY(ch)    PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]
-@@ -1834,6 +1841,9 @@
- #define _pcre2_default_compile_context PCRE2_SUFFIX(_pcre2_default_compile_context_)
- #define _pcre2_default_match_context   PCRE2_SUFFIX(_pcre2_default_match_context_)
- #define _pcre2_default_tables          PCRE2_SUFFIX(_pcre2_default_tables_)
-+#if PCRE2_CODE_UNIT_WIDTH == 32
-+#define _pcre2_dummy_ucd_record        PCRE2_SUFFIX(_pcre2_dummy_ucd_record_)
-+#endif
- #define _pcre2_hspace_list             PCRE2_SUFFIX(_pcre2_hspace_list_)
- #define _pcre2_vspace_list             PCRE2_SUFFIX(_pcre2_vspace_list_)
- #define _pcre2_ucd_caseless_sets       PCRE2_SUFFIX(_pcre2_ucd_caseless_sets_)
-@@ -1858,6 +1868,9 @@
- extern const uint32_t                  PRIV(vspace_list)[];
- extern const uint32_t                  PRIV(ucd_caseless_sets)[];
- extern const ucd_record                PRIV(ucd_records)[];
-+#if PCRE2_CODE_UNIT_WIDTH == 32
-+extern const ucd_record                PRIV(dummy_ucd_record)[];
-+#endif
- extern const uint8_t                   PRIV(ucd_stage1)[];
- extern const uint16_t                  PRIV(ucd_stage2)[];
- extern const uint32_t                  PRIV(ucp_gbtable)[];
diff --git a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/libpcre2-CVE-2017-8786.patch b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/libpcre2-CVE-2017-8786.patch
deleted file mode 100644
index eafafc1..0000000
--- a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/libpcre2-CVE-2017-8786.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-libpcre2-10.23: Fix CVE-2017-8786
-
-The pcre2test.c in PCRE2 10.23 allows remote attackers to cause a denial of
-service (heap-based buffer overflow) or possibly have unspecified other impact
-via a crafted regular expression.
-
-Upstream-Status: Backport [https://vcs.pcre.org/pcre2/code/trunk/src/pcre2test.c?r1=692&r2=697&view=patch]
-CVE: CVE-2017-8786
-
-Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
-
---- trunk/src/pcre2test.c  2017/03/21 16:18:54 692
-+++ trunk/src/pcre2test.c  2017/03/21 18:36:13 697
-@@ -1017,9 +1017,9 @@
-   if (test_mode == PCRE8_MODE) \
-     r = pcre2_get_error_message_8(a,G(b,8),G(G(b,8),_size)); \
-   else if (test_mode == PCRE16_MODE) \
--    r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size)); \
-+    r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size/2)); \
-   else \
--    r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size))
-+    r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size/4))
- 
- #define PCRE2_GET_OVECTOR_COUNT(a,b) \
-   if (test_mode == PCRE8_MODE) \
-@@ -1399,6 +1399,9 @@
- 
- /* ----- Common macros for two-mode cases ----- */
- 
-+#define BYTEONE (BITONE/8)
-+#define BYTETWO (BITTWO/8)
-+
- #define CASTFLD(t,a,b) \
-   ((test_mode == G(G(PCRE,BITONE),_MODE))? (t)(G(a,BITONE)->b) : \
-     (t)(G(a,BITTWO)->b))
-@@ -1481,9 +1484,9 @@
- 
- #define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
-   if (test_mode == G(G(PCRE,BITONE),_MODE)) \
--    r = G(pcre2_get_error_message_,BITONE)(a,G(b,BITONE),G(G(b,BITONE),_size)); \
-+    r = G(pcre2_get_error_message_,BITONE)(a,G(b,BITONE),G(G(b,BITONE),_size/BYTEONE)); \
-   else \
--    r = G(pcre2_get_error_message_,BITTWO)(a,G(b,BITTWO),G(G(b,BITTWO),_size))
-+    r = G(pcre2_get_error_message_,BITTWO)(a,G(b,BITTWO),G(G(b,BITTWO),_size/BYTETWO))
- 
- #define PCRE2_GET_OVECTOR_COUNT(a,b) \
-   if (test_mode == G(G(PCRE,BITONE),_MODE)) \
-@@ -1904,7 +1907,7 @@
- #define PCRE2_DFA_MATCH(a,b,c,d,e,f,g,h,i,j) \
-   a = pcre2_dfa_match_16(G(b,16),(PCRE2_SPTR16)c,d,e,f,G(g,16),h,i,j)
- #define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
--  r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size))
-+  r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size/2))
- #define PCRE2_GET_OVECTOR_COUNT(a,b) a = pcre2_get_ovector_count_16(G(b,16))
- #define PCRE2_GET_STARTCHAR(a,b) a = pcre2_get_startchar_16(G(b,16))
- #define PCRE2_JIT_COMPILE(r,a,b) r = pcre2_jit_compile_16(G(a,16),b)
-@@ -2000,7 +2003,7 @@
- #define PCRE2_DFA_MATCH(a,b,c,d,e,f,g,h,i,j) \
-   a = pcre2_dfa_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),h,i,j)
- #define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
--  r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size))
-+  r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size/4))
- #define PCRE2_GET_OVECTOR_COUNT(a,b) a = pcre2_get_ovector_count_32(G(b,32))
- #define PCRE2_GET_STARTCHAR(a,b) a = pcre2_get_startchar_32(G(b,32))
- #define PCRE2_JIT_COMPILE(r,a,b) r = pcre2_jit_compile_32(G(a,32),b)
-@@ -2889,7 +2892,7 @@
-   {
-   if (pbuffer32 != NULL) free(pbuffer32);
-   pbuffer32_size = 4*len + 4;
--  if (pbuffer32_size < 256) pbuffer32_size = 256;
-+  if (pbuffer32_size < 512) pbuffer32_size = 512;
-   pbuffer32 = (uint32_t *)malloc(pbuffer32_size);
-   if (pbuffer32 == NULL)
-     {
-@@ -7600,7 +7603,8 @@
-   int errcode;
-   char *endptr;
- 
--/* Ensure the relevant non-8-bit buffer is available. */
-+/* Ensure the relevant non-8-bit buffer is available. Ensure that it is at 
-+least 128 code units, because it is used for retrieving error messages. */
- 
- #ifdef SUPPORT_PCRE2_16
-   if (test_mode == PCRE16_MODE)
-@@ -7620,7 +7624,7 @@
- #ifdef SUPPORT_PCRE2_32
-   if (test_mode == PCRE32_MODE)
-     {
--    pbuffer32_size = 256;
-+    pbuffer32_size = 512;
-     pbuffer32 = (uint32_t *)malloc(pbuffer32_size);
-     if (pbuffer32 == NULL)
-       {
diff --git a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/pcre-cross.patch b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/pcre-cross.patch
index 9516caf..871cdfc 100644
--- a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/pcre-cross.patch
+++ b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2/pcre-cross.patch
@@ -9,11 +9,11 @@
 
 Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
 
-diff --git a/Makefile.am b/Makefile.am
-index 38f1d41..2bde083 100644
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -298,9 +298,21 @@ bin_SCRIPTS = pcre2-config
+Index: pcre2-10.30/Makefile.am
+===================================================================
+--- pcre2-10.30.orig/Makefile.am
++++ pcre2-10.30/Makefile.am
+@@ -325,9 +325,21 @@ bin_SCRIPTS = pcre2-config
  ## to copy a distributed set of tables that are defined for ASCII code. In this
  ## case, dftables is not needed.
  
@@ -35,13 +35,13 @@
  src/pcre2_chartables.c: dftables$(EXEEXT)
  	rm -f $@
  	./dftables$(EXEEXT) $@
-diff --git a/configure.ac b/configure.ac
-index d7c57aa..d6eb0aa 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -59,6 +59,23 @@ then
-   fi
- fi
+Index: pcre2-10.30/configure.ac
+===================================================================
+--- pcre2-10.30.orig/configure.ac
++++ pcre2-10.30/configure.ac
+@@ -60,6 +60,23 @@ fi
+ # This is a new thing required to stop a warning from automake 1.12
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
  
 +if test x"$cross_compiling" = xyes; then
 +    CC_FOR_BUILD="${CC_FOR_BUILD-gcc}"
diff --git a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2_10.23.bb b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2_10.30.bb
similarity index 79%
rename from import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2_10.23.bb
rename to import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2_10.30.bb
index ca2b028..46c2d63 100644
--- a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2_10.23.bb
+++ b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre2_10.30.bb
@@ -8,16 +8,14 @@
 HOMEPAGE = "http://www.pcre.org"
 SECTION = "devel"
 LICENSE = "BSD"
-LIC_FILES_CHKSUM = "file://LICENCE;md5=3de34df49e1fe3c3b59a08dff214488b"
+LIC_FILES_CHKSUM = "file://LICENCE;md5=12d55e15a0c6da5c645ba40382bd3293"
 
 SRC_URI = "https://ftp.pcre.org/pub/pcre/pcre2-${PV}.tar.bz2 \
            file://pcre-cross.patch \
-           file://libpcre2-CVE-2017-8786.patch \
-           file://libpcre2-CVE-2017-7186.patch \
 "
 
-SRC_URI[md5sum] = "b2cd00ca7e24049040099b0a46bb3649"
-SRC_URI[sha256sum] = "dfc79b918771f02d33968bd34a749ad7487fa1014aeb787fad29dd392b78c56e"
+SRC_URI[md5sum] = "d3adf4b130eed854a530390f00020a65"
+SRC_URI[sha256sum] = "90bd41c605d30e3745771eb81928d779f158081a51b2f314bbcc1f73de5773db"
 
 CVE_PRODUCT = "pcre2"
 
@@ -35,8 +33,9 @@
     --enable-rebuild-chartables \
     --with-link-size=2 \
     --with-match-limit=10000000 \
+    --enable-pcre2-16 \
+    --enable-pcre2-32 \
 "
-
 # Set LINK_SIZE in BUILD_CFLAGS given that the autotools bbclass use it to
 # set CFLAGS_FOR_BUILD, required for the libpcre build.
 BUILD_CFLAGS =+ "-DLINK_SIZE=2 -I${B}/src"
@@ -45,13 +44,15 @@
 
 export CCLD_FOR_BUILD ="${BUILD_CCLD}"
 
-PACKAGES =+ "pcre2grep pcre2grep-doc pcre2test pcre2test-doc"
+PACKAGES =+ "libpcre2-16 libpcre2-32 pcre2grep pcre2grep-doc pcre2test pcre2test-doc"
 
 SUMMARY_pcre2grep = "grep utility that uses perl 5 compatible regexes"
 SUMMARY_pcre2grep-doc = "grep utility that uses perl 5 compatible regexes - docs"
 SUMMARY_pcre2test = "program for testing Perl-comatible regular expressions"
 SUMMARY_pcre2test-doc = "program for testing Perl-comatible regular expressions - docs"
 
+FILES_libpcre2-16 = "${libdir}/libpcre2-16.so.*"
+FILES_libpcre2-32 = "${libdir}/libpcre2-32.so.*"
 FILES_pcre2grep = "${bindir}/pcre2grep"
 FILES_pcre2grep-doc = "${mandir}/man1/pcre2grep.1"
 FILES_pcre2test = "${bindir}/pcre2test"
diff --git a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre_8.41.bb b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre_8.41.bb
index 0eaed18..0187c08 100644
--- a/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre_8.41.bb
+++ b/import-layers/yocto-poky/meta/recipes-support/libpcre/libpcre_8.41.bb
@@ -80,4 +80,8 @@
 	for i in RunTest RunGrepTest test-driver; \
 	  do cp ${S}/$i $t; \
 	done
+	# Skip the fr_FR locale test. If the locale fr_FR is found, it is tested.
+	# If not found, the test is skipped. The test program assumes fr_FR is non-UTF-8
+	# locale so the test fails if fr_FR is UTF-8 locale.
+	sed -i -e 's:do3=yes:do3=no:g' ${D}${PTEST_PATH}/RunTest 
 }