code:
Copied from Debian.

; You can calculate where the next frame will start depending on things
; like the bitrate. See mad_header_decode().  It seems that when decoding
; the frame you can go past that boundary.  This attempts to catch those cases,
; but might not catch all of them.
; For more info see http://bugs.debian.org/508133
Index: libmad-0.15.1b/layer12.c
===================================================================
--- libmad-0.15.1b.orig/layer12.c	2008-12-23 21:38:07.000000000 +0100
+++ libmad-0.15.1b/layer12.c	2008-12-23 21:38:12.000000000 +0100
@@ -134,6 +134,12 @@
   for (sb = 0; sb < bound; ++sb) {
     for (ch = 0; ch < nch; ++ch) {
       nb = mad_bit_read(&stream->ptr, 4);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

       if (nb == 15) {
 	stream->error = MAD_ERROR_BADBITALLOC;
@@ -146,6 +152,12 @@

   for (sb = bound; sb < 32; ++sb) {
     nb = mad_bit_read(&stream->ptr, 4);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

     if (nb == 15) {
       stream->error = MAD_ERROR_BADBITALLOC;
@@ -162,6 +174,12 @@
     for (ch = 0; ch < nch; ++ch) {
       if (allocation[ch][sb]) {
 	scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 # if defined(OPT_STRICT)
 	/*
@@ -187,6 +205,12 @@
 	frame->sbsample[ch][s][sb] = nb ?
 	  mad_f_mul(I_sample(&stream->ptr, nb),
 		    sf_table[scalefactor[ch][sb]]) : 0;
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
       }
     }

@@ -195,6 +219,12 @@
 	mad_fixed_t sample;

 	sample = I_sample(&stream->ptr, nb);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 	for (ch = 0; ch < nch; ++ch) {
 	  frame->sbsample[ch][s][sb] =
@@ -403,7 +433,15 @@
     nbal = bitalloc_table[offsets[sb]].nbal;

     for (ch = 0; ch < nch; ++ch)
+    {
       allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
+    }
   }

   for (sb = bound; sb < sblimit; ++sb) {
@@ -411,6 +449,13 @@

     allocation[0][sb] =
     allocation[1][sb] = mad_bit_read(&stream->ptr, nbal);
+
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
   }

   /* decode scalefactor selection info */
@@ -419,6 +464,12 @@
     for (ch = 0; ch < nch; ++ch) {
       if (allocation[ch][sb])
 	scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
     }
   }

@@ -442,6 +493,12 @@
     for (ch = 0; ch < nch; ++ch) {
       if (allocation[ch][sb]) {
 	scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 	switch (scfsi[ch][sb]) {
 	case 2:
@@ -452,11 +509,23 @@

 	case 0:
 	  scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6);
+		if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+		{
+			stream->error = MAD_ERROR_LOSTSYNC;
+			stream->sync = 0;
+			return -1;
+		}
 	  /* fall through */

 	case 1:
 	case 3:
 	  scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6);
+		if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+		{
+			stream->error = MAD_ERROR_LOSTSYNC;
+			stream->sync = 0;
+			return -1;
+		}
 	}

 	if (scfsi[ch][sb] & 1)
@@ -488,6 +557,12 @@
 	  index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];

 	  II_samples(&stream->ptr, &qc_table[index], samples);
+		if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+		{
+			stream->error = MAD_ERROR_LOSTSYNC;
+			stream->sync = 0;
+			return -1;
+		}

 	  for (s = 0; s < 3; ++s) {
 	    frame->sbsample[ch][3 * gr + s][sb] =
@@ -506,6 +581,12 @@
 	index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];

 	II_samples(&stream->ptr, &qc_table[index], samples);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 	for (ch = 0; ch < nch; ++ch) {
 	  for (s = 0; s < 3; ++s) {
Index: libmad-0.15.1b/layer3.c
===================================================================
--- libmad-0.15.1b.orig/layer3.c	2008-12-23 21:38:07.000000000 +0100
+++ libmad-0.15.1b/layer3.c	2008-12-23 21:38:12.000000000 +0100
@@ -2608,6 +2608,12 @@
     next_md_begin = 0;

   md_len = si.main_data_begin + frame_space - next_md_begin;
+  if (md_len + MAD_BUFFER_GUARD > MAD_BUFFER_MDLEN)
+  {
+	stream->error = MAD_ERROR_LOSTSYNC;
+	stream->sync = 0;
+	return -1;
+  }

   frame_used = 0;


code:
Fix MIPS assembly code to work with newer GCC, where the "=h"
constraint is no longer supported.

--- libmad/fixed.h.orig	2004-02-16 21:02:03.000000000 -0500
+++ libmad/fixed.h	2011-10-29 18:47:21.000000000 -0400
@@ -304,8 +304,8 @@
  * significant bit depends on OPT_ACCURACY via mad_f_scale64().
  */
 #  define MAD_F_MLX(hi, lo, x, y)  \
-    asm ("mult	%2,%3"  \
-	 : "=l" (lo), "=h" (hi)  \
+    asm ("mult	%2,%3\n\tmfhi  %1"  \
+	 : "=l" (lo), "=r" (hi)  \
 	 : "%r" (x), "r" (y))

 # if defined(HAVE_MADD_ASM)

license: mit


code:
From 1b53767b988b339aac8b353327a1542b2a0c0610 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Sun, 15 Apr 2018 22:29:33 +0200
Subject: [PATCH] Fix build with Qt 5.11_beta3 (dropping qt5_use_modules)

---
 CMakeLists.txt       |  3 ---
 src/CMakeLists.txt   |  8 ++++++--
 tests/CMakeLists.txt | 12 +++++++++---
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb006d9..fa4b0cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,9 +34,6 @@ else()
     set( QT_DONT_USE_QTGUI TRUE )
     include( ${QT_USE_FILE} )

-    macro(qt5_use_modules)
-    endmacro()
-
     macro(qt_wrap_cpp)
         qt4_wrap_cpp(${ARGN})
     endmacro()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 802125b..253e81e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -79,9 +79,13 @@ QT_WRAP_CPP(LIBMYGPO_QT_MOC_SRC ${LIBMYGPO_QT_MOC_H} )

 add_library( ${MYGPO_QT_TARGET_NAME} SHARED ${LIBMYGPO_QT_SRC} ${LIBMYGPO_QT_MOC_SRC} )

-target_link_libraries( ${MYGPO_QT_TARGET_NAME} ${QJSON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY}  )
 set_target_properties( ${MYGPO_QT_TARGET_NAME} PROPERTIES VERSION ${MYGPO_QT_VERSION} SOVERSION ${MYGPO_QT_SONAME} DEFINE_SYMBOL MYGPO_MAKEDLL)
-qt5_use_modules( ${MYGPO_QT_TARGET_NAME} Core Network )
+
+if( NOT BUILD_WITH_QT4 )
+    target_link_libraries( ${MYGPO_QT_TARGET_NAME} Qt5::Core Qt5::Network)
+else()
+    target_link_libraries( ${MYGPO_QT_TARGET_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QJSON_LIBRARIES})
+endif()

 install( TARGETS ${MYGPO_QT_TARGET_NAME} EXPORT ${MYGPO_QT_TARGET_NAME}Export DESTINATION ${LIB_INSTALL_DIR} )

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index a3e3223..4f77158 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -11,11 +11,15 @@ include_directories( ${QJSON_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CU

 # UrlBuilder library
 add_library( UrlBuilder ${TESTOBJECTS_SRCDIR}/UrlBuilder.cpp ${TESTOBJECTS_SRCDIR}/Config.cpp )
-qt5_use_modules( UrlBuilder Core )
+if( NOT BUILD_WITH_QT4 )
+    target_link_libraries( UrlBuilder Qt5::Core )
+endif()
 # JSONCreator library
 QT_WRAP_CPP(LIBMYGPO_QT_MOC_SRC ${TESTOBJECTS_SRCDIR}/EpisodeAction.h ${TESTOBJECTS_SRCDIR}/EpisodeAction_p.h )
 add_library( JsonCreator ${TESTOBJECTS_SRCDIR}/JsonCreator.cpp ${TESTOBJECTS_SRCDIR}/EpisodeAction.cpp ${TESTOBJECTS_SRCDIR}/qjsonwrapper/Json.cpp ${LIBMYGPO_QT_MOC_SRC})
-qt5_use_modules( JsonCreator Core Network )
+if( NOT BUILD_WITH_QT4 )
+    target_link_libraries( JsonCreator Qt5::Core Qt5::Network )
+endif()

 set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )

@@ -25,7 +29,9 @@ macro(add_libmygpo_test _source)
     add_executable(${_name} ${_source} ${${_name}_MOC_SRC})
     target_link_libraries(${_name} ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTNETWORK_LIBRARY})
     add_test(${_name}-test ${EXECUTABLE_OUTPUT_PATH}/${_name})
-    qt5_use_modules(${_name} Network Test)
+    if( NOT BUILD_WITH_QT4 )
+        target_link_libraries(${_name} Qt5::Network Qt5::Test)
+    endif()
 endmacro(add_libmygpo_test)

 add_libmygpo_test( UrlBuilderTest.cpp )


code:
From 0d76d960727018bddf04c6cc89552af69aaa7e55 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Sun, 15 Apr 2018 22:20:34 +0200
Subject: [PATCH] Add missing Qt5Network, Qt5Test, make BUILD_WITH_QT4 more
 strict

---
 CMakeLists.txt | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2a1f652..eb006d9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,25 +5,25 @@ project( libmygpo-qt )
 set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII" )

-option(BUILD_WITH_QT4 "Build libmygpo-qt with Qt4 no matter if Qt5 was found" OFF)
+option(BUILD_WITH_QT4 "Build libmygpo-qt with Qt4" OFF)

 if( NOT BUILD_WITH_QT4 )
-    find_package(Qt5Core QUIET)
-    if( Qt5Core_DIR )
-        set(MYGPO_QT_VERSION_SUFFIX 5)
-
-        macro(qt_wrap_cpp)
-            qt5_wrap_cpp(${ARGN})
-        endmacro()
+    if( MYGPO_BUILD_TESTS )
+        find_package(Qt5 REQUIRED COMPONENTS Core Network Test CONFIG)
+    else()
+        find_package(Qt5 REQUIRED COMPONENTS Core Network CONFIG)
     endif()
+    set(MYGPO_QT_VERSION_SUFFIX 5)
+
+    macro(qt_wrap_cpp)
+        qt5_wrap_cpp(${ARGN})
+    endmacro()

     # pkg-config names of QtCore and QtNetwork are Qt5Core and Qt5Network for
     # Qt5
     set(MYGPO_QT_MAJOR_VERSION "5")
     set(MYGPO_QT4_QJSON_DEP "")
-endif()
-
-if( NOT Qt5Core_DIR )
+else()
     message(STATUS "Could not find Qt5, searching for Qt4 instead...")
     message(STATUS "Qt4 Support is deprecated, building with Qt4 is no longer officially supported")
     if( MYGPO_BUILD_TESTS )


code:
Initialize the context in 'test_auth_clear'.
Fixes the test suite on mips64el.

Patch by Mark H Weaver <mhw@netris.org>

--- libotr-4.1.1/tests/unit/test_auth.c.orig	2015-12-25 12:39:45.000000000 -0500
+++ libotr-4.1.1/tests/unit/test_auth.c	2016-03-17 18:53:10.169999706 -0400
@@ -67,6 +67,7 @@
 	OtrlAuthInfo *auth = &ctx.auth;

 	/* API call. */
+	otrl_auth_new(&ctx);
 	otrl_auth_clear(auth);

 	ok(auth->authstate == OTRL_AUTHSTATE_NONE &&


code:
Fix build with GLM 0.9.9.

This patch is an amalgamation of these upstream commits:

https://github.com/LibreOffice/core/commit/953c4add8fd76d88f49a81ae4c21a1fdcc007e57
https://github.com/LibreOffice/core/commit/5f1bf6598b5725ad1e50ae9f7ec7524cc8a834fa

diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 28bc87b89057..69d4c0552636 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -23,6 +23,12 @@ $(eval $(call gb_Library_add_defs,chartcore,\
     -DOOO_DLLIMPLEMENTATION_CHARTVIEW \
 ))

+ifeq ($(SYSTEM_GLM),TRUE)
+$(eval $(call gb_Library_add_defs,chartcore,\
+        -DGLM_ENABLE_EXPERIMENTAL \
+))
+endif
+
 $(eval $(call gb_Library_set_precompiled_header,chartcore,$(SRCDIR)/chart2/inc/pch/precompiled_chartcore))

 $(eval $(call gb_Library_use_externals,chartcore,\
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index c1f3cc5324e7..0b684c6185a9 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -49,6 +49,12 @@ $(eval $(call gb_Library_add_defs,vcl,\
 	-DENABLE_MERGELIBS=$(if $(MERGELIBS),1,0) \
 ))

+ifeq ($(SYSTEM_GLM),TRUE)
+$(eval $(call gb_Library_add_defs,vcl,\
+        -DGLM_ENABLE_EXPERIMENTAL \
+))
+endif
+
 $(eval $(call gb_Library_use_sdk_api,vcl))

 $(eval $(call gb_Library_use_custom_headers,vcl,\
diff --git a/vcl/Executable_icontest.mk b/vcl/Executable_icontest.mk
index ce163303f8a4..8c917b71cd0e 100644
--- a/vcl/Executable_icontest.mk
+++ b/vcl/Executable_icontest.mk
@@ -19,6 +19,12 @@ $(eval $(call gb_Executable_use_externals,icontest,\
 ))
 endif

+ifeq ($(SYSTEM_GLM),TRUE)
+$(eval $(call gb_Executable_add_defs,icontest,\
+    -DGLM_ENABLE_EXPERIMENTAL \
+))
+endif
+
 $(eval $(call gb_Executable_use_api,icontest,\
     offapi \
     udkapi \


code:
This patch fixes the build of Libreoffice 6.0.5 with icu 61.1.
It was downloaded from https://bugs.gentoo.org/651702.

--- a/forms/source/xforms/datatypes.hxx
+++ a/forms/source/xforms/datatypes.hxx
@@ -36,6 +36,8 @@

 #include <memory>

+using icu::RegexMatcher;
+

 namespace xforms
 {
--- a/i18npool/inc/collator_unicode.hxx
+++ a/i18npool/inc/collator_unicode.hxx
@@ -26,6 +26,8 @@

 #include <unicode/tblcoll.h>

+using icu::RuleBasedCollator;
+
 //      ----------------------------------------------------
 //      class Collator_Unicode
 //      ----------------------------------------------------
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ a/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -30,6 +30,9 @@
 #include <rtl/ustring.hxx>
 #include <string.h>

+using icu::BreakIterator;
+using icu::RuleBasedBreakIterator;
+
 U_CDECL_BEGIN
 extern const char OpenOffice_dat[];
 U_CDECL_END
--- a/i18npool/source/collator/collator_unicode.cxx
+++ a/i18npool/source/collator/collator_unicode.cxx
@@ -29,6 +29,8 @@
 #include <com/sun/star/i18n/CollatorOptions.hpp>
 #include <cppuhelper/supportsservice.hxx>

+using icu::Collator;
+
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::i18n;
 using namespace ::com::sun::star::lang;
--- a/i18npool/source/collator/gencoll_rule.cxx
+++ a/i18npool/source/collator/gencoll_rule.cxx
@@ -31,6 +31,8 @@

 #include <unicode/tblcoll.h>

+using icu::RuleBasedCollator;
+
 /* Main Procedure */

 void data_write(char* file, char* name, sal_uInt8 *data, sal_Int32 len)
--- a/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
+++ a/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
@@ -29,6 +29,8 @@
 #include <unicode/normlzr.h>
 #include <memory>

+using icu::NumberFormat;
+
 using namespace ::com::sun::star::i18n;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star;
--- a/i18npool/source/transliteration/ignoreDiacritics_CTL.cxx
+++ a/i18npool/source/transliteration/ignoreDiacritics_CTL.cxx
@@ -12,6 +12,8 @@
 #include <unicode/translit.h>
 #include <unicode/uchar.h>

+using icu::UnicodeString;
+
 namespace i18npool {

 ignoreDiacritics_CTL::ignoreDiacritics_CTL()
--- a/i18nutil/source/utility/unicode.cxx
+++ a/i18nutil/source/utility/unicode.cxx
@@ -34,6 +34,9 @@
 // which (obviously) breaks UnicodeType::CURRENCY_SYMBOL
 #undef CURRENCY_SYMBOL

+using icu::NumberFormat;
+using icu::UnicodeString;
+
 using namespace ::com::sun::star::i18n;

 template<class L, typename T>
--- a/lotuswordpro/source/filter/localtime.cxx
+++ a/lotuswordpro/source/filter/localtime.cxx
@@ -57,6 +57,8 @@
 #include <limits.h>
 #include <unicode/timezone.h>

+using icu::TimeZone;
+
 const long DAY_SEC =24 * 60 * 60;
 const long YEAR_SEC = 365 * DAY_SEC;
 const long FOURYEAR_SEC = 4 * YEAR_SEC + DAY_SEC;
--- a/opencl/source/openclconfig.cxx
+++ a/opencl/source/openclconfig.cxx
@@ -17,6 +17,8 @@
 #include <sal/log.hxx>
 #include <sal/types.h>

+using icu::RegexMatcher;
+
 OpenCLConfig::OpenCLConfig() :
     mbUseOpenCL(true)
 {
--- a/vcl/inc/scrptrun.h
+++ a/vcl/inc/scrptrun.h
@@ -45,6 +45,8 @@
 #include <unicode/uscript.h>
 #include <vector>

+using icu::UObject;
+
 namespace vcl {

 struct ParenStackEntry


code:
Fix CVE-2017-12562:

https://github.com/erikd/libsndfile/issues/292
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-12562

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8

From cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= <osmanx@problemloesungsmaschine.de>
Date: Wed, 14 Jun 2017 12:25:40 +0200
Subject: [PATCH] src/common.c: Fix heap buffer overflows when writing strings
 in binheader

Fixes the following problems:
 1. Case 's' only enlarges the buffer by 16 bytes instead of size bytes.
 2. psf_binheader_writef() enlarges the header buffer (if needed) prior to the
    big switch statement by an amount (16 bytes) which is enough for all cases
    where only a single value gets added. Cases 's', 'S', 'p' however
    additionally write an arbitrary length block of data and again enlarge the
    buffer to the required amount. However, the required space calculation does
    not take into account the size of the length field which gets output before
    the data.
 3. Buffer size requirement calculation in case 'S' does not account for the
    padding byte ("size += (size & 1) ;" happens after the calculation which
    uses "size").
 4. Case 'S' can overrun the header buffer by 1 byte when no padding is
    involved
    ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;" while
    the buffer is only guaranteed to have "size" space available).
 5. "psf->header.ptr [psf->header.indx] = 0 ;" in case 'S' always writes 1 byte
    beyond the space which is guaranteed to be allocated in the header buffer.
 6. Case 's' can overrun the provided source string by 1 byte if padding is
    involved ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;"
    where "size" is "strlen (strptr) + 1" (which includes the 0 terminator,
    plus optionally another 1 which is padding and not guaranteed to be
    readable via the source string pointer).

Closes: https://github.com/erikd/libsndfile/issues/292
---
 src/common.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/common.c b/src/common.c
index 1a6204ca..6b2a2ee9 100644
--- a/src/common.c
+++ b/src/common.c
@@ -681,16 +681,16 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
 					/* Write a C string (guaranteed to have a zero terminator). */
 					strptr = va_arg (argptr, char *) ;
 					size = strlen (strptr) + 1 ;
-					size += (size & 1) ;

-					if (psf->header.indx + (sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, 16))
+					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
 						return count ;

 					if (psf->rwf_endian == SF_ENDIAN_BIG)
-						header_put_be_int (psf, size) ;
+						header_put_be_int (psf, size + (size & 1)) ;
 					else
-						header_put_le_int (psf, size) ;
+						header_put_le_int (psf, size + (size & 1)) ;
 					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
+					size += (size & 1) ;
 					psf->header.indx += size ;
 					psf->header.ptr [psf->header.indx - 1] = 0 ;
 					count += 4 + size ;
@@ -703,16 +703,15 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
 					*/
 					strptr = va_arg (argptr, char *) ;
 					size = strlen (strptr) ;
-					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
+					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
 						return count ;
 					if (psf->rwf_endian == SF_ENDIAN_BIG)
 						header_put_be_int (psf, size) ;
 					else
 						header_put_le_int (psf, size) ;
-					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;
+					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + (size & 1)) ;
 					size += (size & 1) ;
 					psf->header.indx += size ;
-					psf->header.ptr [psf->header.indx] = 0 ;
 					count += 4 + size ;
 					break ;

@@ -724,7 +723,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
 					size = (size & 1) ? size : size + 1 ;
 					size = (size > 254) ? 254 : size ;

-					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
+					if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
 						return count ;

 					header_put_byte (psf, size) ;


code:
Fix CVE-2017-{8361,8363,8365}:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8361
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8363
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8365

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/fd0484aba8e51d16af1e3a880f9b8b857b385eb3

From fd0484aba8e51d16af1e3a880f9b8b857b385eb3 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Wed, 12 Apr 2017 19:45:30 +1000
Subject: [PATCH] FLAC: Fix a buffer read overrun

Buffer read overrun occurs when reading a FLAC file that switches
from 2 channels to one channel mid-stream. Only option is to
abort the read.

Closes: https://github.com/erikd/libsndfile/issues/230
---
 src/common.h  |  1 +
 src/flac.c    | 13 +++++++++++++
 src/sndfile.c |  1 +
 3 files changed, 15 insertions(+)

diff --git a/src/common.h b/src/common.h
index 0bd810c3..e2669b6a 100644
--- a/src/common.h
+++ b/src/common.h
@@ -725,6 +725,7 @@ enum
 	SFE_FLAC_INIT_DECODER,
 	SFE_FLAC_LOST_SYNC,
 	SFE_FLAC_BAD_SAMPLE_RATE,
+	SFE_FLAC_CHANNEL_COUNT_CHANGED,
 	SFE_FLAC_UNKOWN_ERROR,

 	SFE_WVE_NOT_WVE,
diff --git a/src/flac.c b/src/flac.c
index 84de0e26..986a7b8f 100644
--- a/src/flac.c
+++ b/src/flac.c
@@ -434,6 +434,19 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_

 	switch (metadata->type)
 	{	case FLAC__METADATA_TYPE_STREAMINFO :
+			if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
+			{	psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
+									"Nothing to be but to error out.\n" ,
+									psf->sf.channels, metadata->data.stream_info.channels) ;
+				psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
+				return ;
+				} ;
+
+			if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate)
+			{	psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n"
+									"Carrying on as if nothing happened.",
+									psf->sf.samplerate, metadata->data.stream_info.sample_rate) ;
+				} ;
 			psf->sf.channels = metadata->data.stream_info.channels ;
 			psf->sf.samplerate = metadata->data.stream_info.sample_rate ;
 			psf->sf.frames = metadata->data.stream_info.total_samples ;
diff --git a/src/sndfile.c b/src/sndfile.c
index 41875610..e2a87be8 100644
--- a/src/sndfile.c
+++ b/src/sndfile.c
@@ -245,6 +245,7 @@ ErrorStruct SndfileErrors [] =
 	{	SFE_FLAC_INIT_DECODER	, "Error : problem with initialization of the flac decoder." },
 	{	SFE_FLAC_LOST_SYNC		, "Error : flac decoder lost sync." },
 	{	SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." },
+	{	SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." },
 	{	SFE_FLAC_UNKOWN_ERROR	, "Error : unknown error in flac decoder." },

 	{	SFE_WVE_NOT_WVE			, "Error : not a WVE file." },
--
2.12.2


code:
Fix CVE-2017-8362:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8362

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/ef1dbb2df1c0e741486646de40bd638a9c4cd808

From ef1dbb2df1c0e741486646de40bd638a9c4cd808 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Fri, 14 Apr 2017 15:19:16 +1000
Subject: [PATCH] src/flac.c: Fix a buffer read overflow

A file (generated by a fuzzer) which increased the number of channels
from one frame to the next could cause a read beyond the end of the
buffer provided by libFLAC. Only option is to abort the read.

Closes: https://github.com/erikd/libsndfile/issues/231
---
 src/flac.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/flac.c b/src/flac.c
index 5a4f8c21..e4f9aaa0 100644
--- a/src/flac.c
+++ b/src/flac.c
@@ -169,6 +169,14 @@ flac_buffer_copy (SF_PRIVATE *psf)
 	const int32_t* const *buffer = pflac->wbuffer ;
 	unsigned i = 0, j, offset, channels, len ;

+	if (psf->sf.channels != (int) frame->header.channels)
+	{	psf_log_printf (psf, "Error: FLAC frame changed from %d to %d channels\n"
+									"Nothing to do but to error out.\n" ,
+									psf->sf.channels, frame->header.channels) ;
+		psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
+		return 0 ;
+		} ;
+
 	/*
 	**	frame->header.blocksize is variable and we're using a constant blocksize
 	**	of FLAC__MAX_BLOCK_SIZE.
@@ -202,7 +210,6 @@ flac_buffer_copy (SF_PRIVATE *psf)
 		return 0 ;
 		} ;

-
 	len = SF_MIN (pflac->len, frame->header.blocksize) ;

 	if (pflac->remain % channels != 0)
@@ -436,7 +443,7 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
 	{	case FLAC__METADATA_TYPE_STREAMINFO :
 			if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
 			{	psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
-									"Nothing to be but to error out.\n" ,
+									"Nothing to do but to error out.\n" ,
 									psf->sf.channels, metadata->data.stream_info.channels) ;
 				psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
 				return ;
--
2.12.2


code:
This is a regression in 1.0.28 that causes a test failure on armhf.

Upstream bug URL:

https://github.com/erikd/libsndfile/issues/229

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/9d470ee5577d3ccedb1c28c7e0a7295ba17feaf5

From 9d470ee5577d3ccedb1c28c7e0a7295ba17feaf5 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Sun, 16 Apr 2017 17:54:17 +1000
Subject: [PATCH] src/rf64.c: Fix varargs related bug

C's <stargs.h> functionality isn't type checked so that passing an
`sf_count_t` (64 bits) by mistake in place of a `unit32_t` can cause
errors. This would be fine if it was an error on every architecture
and platform, but its not. This particular problem only manifested
on armhf and some other Arm architectures. It was not an issue on
32 bit x86.

I have now fixed variants of this same bug several times.

Closes: https://github.com/erikd/libsndfile/issues/229
---
 src/rf64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rf64.c b/src/rf64.c
index b3d637f..02dd904 100644
--- a/src/rf64.c
+++ b/src/rf64.c
@@ -742,7 +742,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length)

 	pad_size = psf->dataoffset - 16 - psf->header.indx ;
 	if (pad_size >= 0)
-		psf_binheader_writef (psf, "m4z", PAD_MARKER, pad_size, make_size_t (pad_size)) ;
+		psf_binheader_writef (psf, "m4z", PAD_MARKER, (unsigned int) pad_size, make_size_t (pad_size)) ;

 	if (wpriv->rf64_downgrade && (psf->filelength < RIFF_DOWNGRADE_BYTES))
 		psf_binheader_writef (psf, "tm8", data_MARKER, psf->datalength) ;


code:
Fix "Hostname" parsing in OpenSSH config files, as reported
at <https://red.libssh.org/issues/260>.

From: Niels Ole Salscheider <niels_ole@salscheider-online.de>
Date: Mon, 8 May 2017 17:36:13 +0200
Subject: [PATCH] Fix reading of the first parameter

This is a fixup for 7b8b5eb4eac314a3a29be812bef0264c6611f6e7.
Previously, it would return as long as the parameter was _not_ seen
before. It also did not handle the case for the unsupported opcode (-1)
which would cause a segfault when accessing the "seen" array.
---
 src/config.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/config.c b/src/config.c
index 7c03b27..238a655 100644
--- a/src/config.c
+++ b/src/config.c
@@ -218,8 +218,9 @@ static int ssh_config_parse_line(ssh_session session, const char *line,
   }

   opcode = ssh_config_get_opcode(keyword);
-  if (*parsing == 1 && opcode != SOC_HOST) {
-      if (seen[opcode] == 0) {
+  if (*parsing == 1 && opcode != SOC_HOST &&
+      opcode > SOC_UNSUPPORTED && opcode < SOC_END) {
+      if (seen[opcode] == 1) {
           return 0;
       }
       seen[opcode] = 1;


code:
This fixes a regression introduced in 1.8.0 where libssh2 fails to build
with the gcrypt backend.

Upstream bug URL:

https://github.com/libssh2/libssh2/issues/150

Patch copied from upstream source repository:

https://github.com/libssh2/libssh2/commit/ced924b78a40126606797ef57a74066eb3b4b83f

From ced924b78a40126606797ef57a74066eb3b4b83f Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Mon, 31 Oct 2016 09:04:33 +0000
Subject: [PATCH] acinclude.m4: fix ./configure --with-libgcrypt

diff --git a/acinclude.m4 b/acinclude.m4
index 734ef07..c78260c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -412,9 +412,9 @@ AC_DEFUN([LIBSSH2_CHECKFOR_GCRYPT], [

   old_LDFLAGS=$LDFLAGS
   old_CFLAGS=$CFLAGS
-  if test -n "$use_libgcrypt" && test "$use_libgcrypt" != "no"; then
-    LDFLAGS="$LDFLAGS -L$use_libgcrypt/lib"
-    CFLAGS="$CFLAGS -I$use_libgcrypt/include"
+  if test -n "$with_libgcrypt_prefix" && test "$use_libgcrypt" != "no"; then
+    LDFLAGS="$LDFLAGS -L$with_libgcrypt_prefix/lib"
+    CFLAGS="$CFLAGS -I$with_libgcrypt_prefix/include"
   fi
   AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [
     #include <gcrypt.h>


code:
Author: Raphael Geissert <geissert@debian.org>
Bug-Debian: https://bugs.debian.org/731860
Description: Avoid directory traversal when extracting archives
 by skipping over leading slashes and any prefix containing ".." components.
Forwarded: yes

--- a/lib/decode.c
+++ b/lib/decode.c
@@ -22,6 +22,36 @@
 #endif

+char *
+safer_name_suffix (char const *file_name)
+{
+	char const *p, *t;
+	p = t = file_name;
+	while (*p == '/') t = ++p;
+	while (*p)
+	{
+		while (p[0] == '.' && p[0] == p[1] && p[2] == '/')
+		{
+			p += 3;
+			t = p;
+		}
+		/* advance pointer past the next slash */
+		while (*p && (p++)[0] != '/');
+	}
+
+	if (!*t)
+	{
+		t = ".";
+	}
+
+	if (t != file_name)
+	{
+		/* TODO: warn somehow that the path was modified */
+	}
+	return (char*)t;
+}
+
+
 /* determine full path name */
 char *
 th_get_pathname(TAR *t)
@@ -29,17 +59,17 @@ th_get_pathname(TAR *t)
 	static char filename[MAXPATHLEN];

 	if (t->th_buf.gnu_longname)
-		return t->th_buf.gnu_longname;
+		return safer_name_suffix(t->th_buf.gnu_longname);

 	if (t->th_buf.prefix[0] != '\0')
 	{
 		snprintf(filename, sizeof(filename), "%.155s/%.100s",
 			 t->th_buf.prefix, t->th_buf.name);
-		return filename;
+		return safer_name_suffix(filename);
 	}

 	snprintf(filename, sizeof(filename), "%.100s", t->th_buf.name);
-	return filename;
+	return safer_name_suffix(filename);
 }

--- a/lib/extract.c
+++ b/lib/extract.c
@@ -298,14 +298,14 @@ tar_extract_hardlink(TAR * t, char *real
 	if (mkdirhier(dirname(filename)) == -1)
 		return -1;
 	libtar_hashptr_reset(&hp);
-	if (libtar_hash_getkey(t->h, &hp, th_get_linkname(t),
+	if (libtar_hash_getkey(t->h, &hp, safer_name_suffix(th_get_linkname(t)),
 			       (libtar_matchfunc_t)libtar_str_match) != 0)
 	{
 		lnp = (char *)libtar_hashptr_data(&hp);
 		linktgt = &lnp[strlen(lnp) + 1];
 	}
 	else
-		linktgt = th_get_linkname(t);
+		linktgt = safer_name_suffix(th_get_linkname(t));

 #ifdef DEBUG
 	printf("  ==> extracting: %s (link to %s)\n", filename, linktgt);
@@ -343,9 +343,9 @@ tar_extract_symlink(TAR *t, char *realna

 #ifdef DEBUG
 	printf("  ==> extracting: %s (symlink to %s)\n",
-	       filename, th_get_linkname(t));
+	       filename, safer_name_suffix(th_get_linkname(t)));
 #endif
-	if (symlink(th_get_linkname(t), filename) == -1)
+	if (symlink(safer_name_suffix(th_get_linkname(t)), filename) == -1)
 	{
 #ifdef DEBUG
 		perror("symlink()");
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -15,3 +15,4 @@

 #include <libtar.h>

+char* safer_name_suffix(char const*);
--- a/lib/output.c
+++ b/lib/output.c
@@ -123,9 +123,9 @@ th_print_long_ls(TAR *t)
 		else
 			printf(" link to ");
 		if ((t->options & TAR_GNU) && t->th_buf.gnu_longlink != NULL)
-			printf("%s", t->th_buf.gnu_longlink);
+			printf("%s", safer_name_suffix(t->th_buf.gnu_longlink));
 		else
-			printf("%.100s", t->th_buf.linkname);
+			printf("%.100s", safer_name_suffix(t->th_buf.linkname));
 	}

 	putchar('\n');


code:
Minimally patch libtheora's ancient config.guess to support mips64.

--- libtheora/config.guess.orig	2009-02-23 22:50:50.000000000 -0500
+++ libtheora/config.guess	2013-10-31 23:49:48.155999944 -0400
@@ -798,25 +798,24 @@
     m68*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
-    mips:Linux:*:*)
+    mips:Linux:*:* | mips64:Linux:*:*)
 	eval $set_cc_for_build
 	sed 's/^	//' << EOF >$dummy.c
 	#undef CPU
-	#undef mips
-	#undef mipsel
+	#undef ${UNAME_MACHINE}
+	#undef ${UNAME_MACHINE}el
 	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=mipsel
+	CPU=${UNAME_MACHINE}el
 	#else
 	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=mips
+	CPU=${UNAME_MACHINE}
 	#else
 	CPU=
 	#endif
 	#endif
 EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
-	rm -f $dummy.c && rmdir $tmpdir
-	test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit 0; }
 	;;
     ppc:Linux:*:*)
 	echo powerpc-unknown-linux-gnu


code:
Fix CVE-2017-18013:

http://bugzilla.maptools.org/show_bug.cgi?id=2770
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-18013

Patch copied from upstream source repository:

https://gitlab.com/libtiff/libtiff/commit/c6f41df7b581402dfba3c19a1e3df4454c551a01

From c6f41df7b581402dfba3c19a1e3df4454c551a01 Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Sun, 31 Dec 2017 15:09:41 +0100
Subject: [PATCH] libtiff/tif_print.c: TIFFPrintDirectory(): fix null pointer
 dereference on corrupted file. Fixes
 http://bugzilla.maptools.org/show_bug.cgi?id=2770

---
 libtiff/tif_print.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c
index 9959d353..8deceb2b 100644
--- a/libtiff/tif_print.c
+++ b/libtiff/tif_print.c
@@ -665,13 +665,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
 			fprintf(fd, "    %3lu: [%8I64u, %8I64u]\n",
 			    (unsigned long) s,
-			    (unsigned __int64) td->td_stripoffset[s],
-			    (unsigned __int64) td->td_stripbytecount[s]);
+			    td->td_stripoffset ? (unsigned __int64) td->td_stripoffset[s] : 0,
+			    td->td_stripbytecount ? (unsigned __int64) td->td_stripbytecount[s] : 0);
 #else
 			fprintf(fd, "    %3lu: [%8llu, %8llu]\n",
 			    (unsigned long) s,
-			    (unsigned long long) td->td_stripoffset[s],
-			    (unsigned long long) td->td_stripbytecount[s]);
+			    td->td_stripoffset ? (unsigned long long) td->td_stripoffset[s] : 0,
+			    td->td_stripbytecount ? (unsigned long long) td->td_stripbytecount[s] : 0);
 #endif
 	}
 }
--
2.16.1


code:
Fix CVE-2017-9935

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-9935
http://bugzilla.maptools.org/show_bug.cgi?id=2704

Patch copied from upstream source repository:

https://gitlab.com/libtiff/libtiff/commit/3dd8f6a357981a4090f126ab9025056c938b6940

From 3dd8f6a357981a4090f126ab9025056c938b6940 Mon Sep 17 00:00:00 2001
From: Brian May <brian@linuxpenguins.xyz>
Date: Thu, 7 Dec 2017 07:46:47 +1100
Subject: [PATCH] tiff2pdf: Fix CVE-2017-9935

Fix for http://bugzilla.maptools.org/show_bug.cgi?id=2704

This vulnerability - at least for the supplied test case - is because we
assume that a tiff will only have one transfer function that is the same
for all pages. This is not required by the TIFF standards.

We than read the transfer function for every page.  Depending on the
transfer function, we allocate either 2 or 4 bytes to the XREF buffer.
We allocate this memory after we read in the transfer function for the
page.

For the first exploit - POC1, this file has 3 pages. For the first page
we allocate 2 extra extra XREF entries. Then for the next page 2 more
entries. Then for the last page the transfer function changes and we
allocate 4 more entries.

When we read the file into memory, we assume we have 4 bytes extra for
each and every page (as per the last transfer function we read). Which
is not correct, we only have 2 bytes extra for the first 2 pages. As a
result, we end up writing past the end of the buffer.

There are also some related issues that this also fixes. For example,
TIFFGetField can return uninitalized pointer values, and the logic to
detect a N=3 vs N=1 transfer function seemed rather strange.

It is also strange that we declare the transfer functions to be of type
float, when the standard says they are unsigned 16 bit values. This is
fixed in another patch.

This patch will check to ensure that the N value for every transfer
function is the same for every page. If this changes, we abort with an
error. In theory, we should perhaps check that the transfer function
itself is identical for every page, however we don't do that due to the
confusion of the type of the data in the transfer function.
---
 libtiff/tif_dir.c |  3 +++
 tools/tiff2pdf.c  | 65 +++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
index 2ccaf448..cbf2b693 100644
--- a/libtiff/tif_dir.c
+++ b/libtiff/tif_dir.c
@@ -1065,6 +1065,9 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
 			if (td->td_samplesperpixel - td->td_extrasamples > 1) {
 				*va_arg(ap, uint16**) = td->td_transferfunction[1];
 				*va_arg(ap, uint16**) = td->td_transferfunction[2];
+			} else {
+				*va_arg(ap, uint16**) = NULL;
+				*va_arg(ap, uint16**) = NULL;
 			}
 			break;
 		case TIFFTAG_REFERENCEBLACKWHITE:
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index d1a9b095..c3ec0746 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -1047,6 +1047,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
 	uint16 pagen=0;
 	uint16 paged=0;
 	uint16 xuint16=0;
+	uint16 tiff_transferfunctioncount=0;
+	float* tiff_transferfunction[3];

 	directorycount=TIFFNumberOfDirectories(input);
 	t2p->tiff_pages = (T2P_PAGE*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,directorycount,sizeof(T2P_PAGE)));
@@ -1147,26 +1149,48 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
                 }
 #endif
 		if (TIFFGetField(input, TIFFTAG_TRANSFERFUNCTION,
-                                 &(t2p->tiff_transferfunction[0]),
-                                 &(t2p->tiff_transferfunction[1]),
-                                 &(t2p->tiff_transferfunction[2]))) {
-			if((t2p->tiff_transferfunction[1] != (float*) NULL) &&
-                           (t2p->tiff_transferfunction[2] != (float*) NULL) &&
-                           (t2p->tiff_transferfunction[1] !=
-                            t2p->tiff_transferfunction[0])) {
-				t2p->tiff_transferfunctioncount = 3;
-				t2p->tiff_pages[i].page_extra += 4;
-				t2p->pdf_xrefcount += 4;
-			} else {
-				t2p->tiff_transferfunctioncount = 1;
-				t2p->tiff_pages[i].page_extra += 2;
-				t2p->pdf_xrefcount += 2;
-			}
-			if(t2p->pdf_minorversion < 2)
-				t2p->pdf_minorversion = 2;
+                                 &(tiff_transferfunction[0]),
+                                 &(tiff_transferfunction[1]),
+                                 &(tiff_transferfunction[2]))) {
+
+                        if((tiff_transferfunction[1] != (float*) NULL) &&
+                           (tiff_transferfunction[2] != (float*) NULL)
+                          ) {
+                            tiff_transferfunctioncount=3;
+                        } else {
+                            tiff_transferfunctioncount=1;
+                        }
                 } else {
-			t2p->tiff_transferfunctioncount=0;
+			tiff_transferfunctioncount=0;
 		}
+
+                if (i > 0){
+                    if (tiff_transferfunctioncount != t2p->tiff_transferfunctioncount){
+                        TIFFError(
+                            TIFF2PDF_MODULE,
+                            "Different transfer function on page %d",
+                            i);
+                        t2p->t2p_error = T2P_ERR_ERROR;
+                        return;
+                    }
+                }
+
+                t2p->tiff_transferfunctioncount = tiff_transferfunctioncount;
+                t2p->tiff_transferfunction[0] = tiff_transferfunction[0];
+                t2p->tiff_transferfunction[1] = tiff_transferfunction[1];
+                t2p->tiff_transferfunction[2] = tiff_transferfunction[2];
+                if(tiff_transferfunctioncount == 3){
+                        t2p->tiff_pages[i].page_extra += 4;
+                        t2p->pdf_xrefcount += 4;
+                        if(t2p->pdf_minorversion < 2)
+                                t2p->pdf_minorversion = 2;
+                } else if (tiff_transferfunctioncount == 1){
+                        t2p->tiff_pages[i].page_extra += 2;
+                        t2p->pdf_xrefcount += 2;
+                        if(t2p->pdf_minorversion < 2)
+                                t2p->pdf_minorversion = 2;
+                }
+
 		if( TIFFGetField(
 			input,
 			TIFFTAG_ICCPROFILE,
@@ -1828,9 +1852,8 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){
 			 &(t2p->tiff_transferfunction[1]),
 			 &(t2p->tiff_transferfunction[2]))) {
 		if((t2p->tiff_transferfunction[1] != (float*) NULL) &&
-                   (t2p->tiff_transferfunction[2] != (float*) NULL) &&
-                   (t2p->tiff_transferfunction[1] !=
-                    t2p->tiff_transferfunction[0])) {
+                   (t2p->tiff_transferfunction[2] != (float*) NULL)
+                  ) {
 			t2p->tiff_transferfunctioncount=3;
 		} else {
 			t2p->tiff_transferfunctioncount=1;
--
2.16.1


code:
Fix CVE-2018-10963:

http://bugzilla.maptools.org/show_bug.cgi?id=2795
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-10963

Patch copied from upstream source repository:

https://gitlab.com/libtiff/libtiff/commit/de144fd228e4be8aa484c3caf3d814b6fa88c6d9

From de144fd228e4be8aa484c3caf3d814b6fa88c6d9 Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Sat, 12 May 2018 14:24:15 +0200
Subject: [PATCH] TIFFWriteDirectorySec: avoid assertion. Fixes
 http://bugzilla.maptools.org/show_bug.cgi?id=2795. CVE-2018-10963

---
 libtiff/tif_dirwrite.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
index 2430de6d..c15a28db 100644
--- a/libtiff/tif_dirwrite.c
+++ b/libtiff/tif_dirwrite.c
@@ -695,8 +695,11 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
 								}
 								break;
 							default:
-								assert(0);   /* we should never get here */
-								break;
+								TIFFErrorExt(tif->tif_clientdata,module,
+								            "Cannot write tag %d (%s)",
+								            TIFFFieldTag(o),
+                                                                            o->field_name ? o->field_name : "unknown");
+								goto bad;
 						}
 					}
 				}
--
2.17.0


code:
Fix CVE-2018-8095:

http://bugzilla.maptools.org/show_bug.cgi?id=2780
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-8905

Patch copied from upstream source repository:

https://gitlab.com/libtiff/libtiff/commit/58a898cb4459055bb488ca815c23b880c242a27d

From 58a898cb4459055bb488ca815c23b880c242a27d Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Sat, 12 May 2018 15:32:31 +0200
Subject: [PATCH] LZWDecodeCompat(): fix potential index-out-of-bounds write.
 Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2780 / CVE-2018-8905

The fix consists in using the similar code LZWDecode() to validate we
don't write outside of the output buffer.
---
 libtiff/tif_lzw.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c
index 4ccb443c..94d85e38 100644
--- a/libtiff/tif_lzw.c
+++ b/libtiff/tif_lzw.c
@@ -602,6 +602,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
 	char *tp;
 	unsigned char *bp;
 	int code, nbits;
+	int len;
 	long nextbits, nextdata, nbitsmask;
 	code_t *codep, *free_entp, *maxcodep, *oldcodep;

@@ -753,13 +754,18 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
 				}  while (--occ);
 				break;
 			}
-			assert(occ >= codep->length);
-			op += codep->length;
-			occ -= codep->length;
-			tp = op;
+			len = codep->length;
+			tp = op + len;
 			do {
-				*--tp = codep->value;
-			} while( (codep = codep->next) != NULL );
+				int t;
+				--tp;
+				t = codep->value;
+				codep = codep->next;
+				*tp = (char)t;
+			} while (codep && tp > op);
+			assert(occ >= len);
+			op += len;
+			occ -= len;
 		} else {
 			*op++ = (char)code;
 			occ--;
--
2.17.0


code:
Skip the nopic test on ARM and MIPS systems.

--- libtool-2.4.6/tests/demo.at.orig	2015-01-16 13:52:04.000000000 -0500
+++ libtool-2.4.6/tests/demo.at	2015-02-16 10:48:51.435851966 -0500
@@ -510,7 +510,7 @@
 AT_SETUP([force non-PIC objects])

 AT_CHECK([case $host in
-hppa*|x86_64*|s390*)
+hppa*|x86_64*|s390*|arm*|mips*)
   # These hosts cannot use non-PIC shared libs
   exit 77 ;;
 *-solaris*|*-sunos*)
--- libtool-2.4.6/tests/testsuite.orig	2015-02-15 11:15:25.000000000 -0500
+++ libtool-2.4.6/tests/testsuite	2015-02-16 10:50:58.736483216 -0500
@@ -8741,7 +8741,7 @@

 { set +x
 $as_echo "$at_srcdir/demo.at:535: case \$host in
-hppa*|x86_64*|s390*)
+hppa*|x86_64*|s390*|arm*|mips*)
   # These hosts cannot use non-PIC shared libs
   exit 77 ;;
 *-solaris*|*-sunos*)
@@ -8766,7 +8766,7 @@
 "
 at_fn_check_prepare_notrace 'a `...` command substitution' "demo.at:535"
 ( $at_check_trace; case $host in
-hppa*|x86_64*|s390*)
+hppa*|x86_64*|s390*|arm*|mips*)
   # These hosts cannot use non-PIC shared libs
   exit 77 ;;
 *-solaris*|*-sunos*)


code:
Disable tests who fail because they have to run as root.

--- libusb-0.1.12/tests/Makefile.in	2006-03-04 03:54:06.000000000 +0100
+++ libusb-0.1.12/tests/Makefile.in	2017-07-13 16:17:45.201728019 +0200
@@ -255,8 +255,8 @@
 hub_strings_LDADD = $(top_builddir)/libusbpp.la @OSLIBS@
 driver_name_SOURCES = driver_name.cpp
 driver_name_LDADD = $(top_builddir)/libusbpp.la @OSLIBS@
-TESTS = testlibusb descriptor_test id_test find_hubs find_mice \
-		get_resolution hub_strings $(OS_SPECIFIC)
+TESTS = testlibusb descriptor_test id_test find_hubs find_mice
+		#get_resolution hub_strings $(OS_SPECIFIC)

 XFAIL_TESTS = get_resolution hub_strings $(OS_SPECIFIC_XFAIL)
 all: all-am


code:
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
index 74d6de5..0b0e314 100644
--- a/libusb/descriptor.c
+++ b/libusb/descriptor.c
@@ -1174,7 +1174,7 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_ha
 		return LIBUSB_ERROR_IO;

 	if (tbuf[0] > r)
-		return LIBUSB_ERROR_IO;
+		tbuf[0] = r;

 	di = 0;
 	for (si = 2; si < tbuf[0]; si += 2) {
--
2.17.0


code:
--- a/libutils/CallStack.cpp	2018-04-25 20:13:06.348665241 +0200
+++ b/libutils/CallStack.cpp	2018-04-25 20:13:18.360510763 +0200
@@ -17,7 +17,7 @@
 #define LOG_TAG "CallStack"

 #include <memory>
-
+#include <cstdlib>
 #include <utils/CallStack.h>
 #include <utils/Printer.h>
 #include <utils/Errors.h>


code:
--- a/include/utils/StrongPointer.h	2018-04-25 18:42:34.321003602 +0200
+++ b/include/utils/StrongPointer.h	2018-04-25 18:42:42.180912201 +0200
@@ -17,8 +17,6 @@
 #ifndef ANDROID_STRONG_POINTER_H
 #define ANDROID_STRONG_POINTER_H

-#include <cutils/atomic.h>
-
 #include <stdint.h>
 #include <sys/types.h>
 #include <stdlib.h>
--- a/libutils/Trace.cpp	2018-04-25 20:41:48.775049786 +0200
+++ b/libutils/Trace.cpp	2018-04-25 20:42:13.674744182 +0200
@@ -21,5 +21,7 @@

 static void traceInit()
 {
+#if defined(__ANDROID__)
     ::android::add_sysprop_change_callback(atrace_update_tags, 0);
+#endif
 }


code:
From 18e3ff648356cf06a39372aa4a4bbf2732d9d0f4 Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@flashner.co.il>
Date: Tue, 12 Dec 2017 21:36:44 +0200
Subject: [PATCH] don't use bundled libvdpau headers

---
 CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0484179..e950707 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,16 +9,17 @@ find_package(PkgConfig REQUIRED)
 find_package(X11 REQUIRED)
 pkg_check_modules(LIBVA      libva-x11  REQUIRED)
 pkg_check_modules(LIBGL      gl         REQUIRED)
+pkg_check_modules(LIBVDPAU   vdpau      REQUIRED)

 set(DRIVER_NAME "vdpau_va_gl" CACHE STRING "driver name")
 set(LIB_SUFFIX "" CACHE STRING "library path suffix (if needed)")
 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/vdpau" CACHE PATH "library installation path")

 include_directories (
-    3rdparty
     ${X11_INCLUDE_DIRS}
     ${LIBVA_INCLUDE_DIRS}
     ${LIBGL_INCLUDE_DIRS}
+    ${LIBVDPAU_INCLUDE_DIRS}
     ${GENERATED_INCLUDE_DIRS}
     ${CMAKE_BINARY_DIR}
 )
--
2.15.1


code:
Patch contents copied from Mozilla esr45 changeset 312077:7ebfe49f001c

  changeset:   312077:7ebfe49f001c
  user:        Randell Jesup <rjesup@jesup.org>
  Date:        Fri Apr 15 23:11:01 2016 -0400
  summary:     Bug 1263384: validate input frames against configured resolution in vp8 r=rillian, a=ritu,lizzard

  MozReview-Commit-ID: BxDCnJe0mzs

--- libvpx-1.5.0/vp8/vp8_cx_iface.c.orig	2015-11-09 17:12:38.000000000 -0500
+++ libvpx-1.5.0/vp8/vp8_cx_iface.c	2016-06-08 08:48:46.037213092 -0400
@@ -860,11 +860,20 @@
     if (img != NULL) {
       res = image2yuvconfig(img, &sd);

-      if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, &sd,
-                                dst_time_stamp, dst_end_time_stamp)) {
-        VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
-        res = update_error_state(ctx, &cpi->common.error);
-      }
+            if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) {
+                /* from vp8_encoder.h for g_w/g_h:
+                   "Note that the frames passed as input to the encoder must have this resolution"
+                */
+                ctx->base.err_detail = "Invalid input frame resolution";
+                res = VPX_CODEC_INVALID_PARAM;
+            } else {
+                if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags,
+                                          &sd, dst_time_stamp, dst_end_time_stamp))
+                {
+                    VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
+                    res = update_error_state(ctx, &cpi->common.error);
+                }
+            }

       /* reset for next frame */
       ctx->next_frame_flag = 0;


code:
From 52add5896661d186dec284ed646a4b33b607d2c7 Mon Sep 17 00:00:00 2001
From: Jerome Jiang <jianj@google.com>
Date: Wed, 23 May 2018 15:43:00 -0700
Subject: [PATCH] VP8: Fix use-after-free in postproc.

The pointer in vp8 postproc refers to show_frame_mi which is only
updated on show frame. However, when there is a no-show frame which also
changes the size (thus new frame buffers allocated), show_frame_mi is
not updated with new frame buffer memory.

Change the pointer in postproc to mi which is always updated.

Bug: 842265
Change-Id: I33874f2112b39f74562cba528432b5f239e6a7bd
---
 vp8/common/postproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c
index d67ee8a57..8c292d616 100644
--- a/vp8/common/postproc.c
+++ b/vp8/common/postproc.c
@@ -65,7 +65,7 @@ void vp8_deblock(VP8_COMMON *cm, YV12_BUFFER_CONFIG *source,
   double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
   int ppl = (int)(level + .5);

-  const MODE_INFO *mode_info_context = cm->show_frame_mi;
+  const MODE_INFO *mode_info_context = cm->mi;
   int mbr, mbc;

   /* The pixel thresholds are adjusted according to if or not the macroblock
--
2.19.0


code:
This makes generated IDs deterministic.

Written by Daniel Veillard.

This should be fixed in next release (2.29).
See https://bugzilla.gnome.org/show_bug.cgi?id=751621.

diff --git a/libxslt/functions.c b/libxslt/functions.c
index 6448bde..5b00a6d 100644
--- a/libxslt/functions.c
+++ b/libxslt/functions.c
@@ -651,6 +651,63 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
 }

 /**
+ * xsltCleanupIds:
+ * @ctxt: the transformation context
+ * @root: the root of the resulting document
+ *
+ * This clean up ids which may have been saved in Element contents
+ * by xsltGenerateIdFunction() to provide stable IDs on elements.
+ *
+ * Returns the number of items cleaned or -1 in case of error
+ */
+int
+xsltCleanupIds(xsltTransformContextPtr ctxt, xmlNodePtr root) {
+    xmlNodePtr cur;
+    int count = 0;
+
+    if ((ctxt == NULL) || (root == NULL))
+        return(-1);
+    if (root->type != XML_ELEMENT_NODE)
+        return(-1);
+
+    cur = root;
+    while (cur != NULL) {
+	if (cur->type == XML_ELEMENT_NODE) {
+	    if (cur->content != NULL) {
+	        cur->content = NULL;
+		count++;
+	    }
+	    if (cur->children != NULL) {
+		cur = cur->children;
+		continue;
+	    }
+	}
+	if (cur->next != NULL) {
+	    cur = cur->next;
+	    continue;
+	}
+	do {
+	    cur = cur->parent;
+	    if (cur == NULL)
+		break;
+	    if (cur == (xmlNodePtr) root) {
+		cur = NULL;
+		break;
+	    }
+	    if (cur->next != NULL) {
+		cur = cur->next;
+		break;
+	    }
+	} while (cur != NULL);
+    }
+
+fprintf(stderr, "Attributed %d IDs for element, cleaned up %d\n",
+        ctxt->nextid, count);
+
+    return(count);
+}
+
+/**
  * xsltGenerateIdFunction:
  * @ctxt:  the XPath Parser context
  * @nargs:  the number of arguments
@@ -701,7 +758,39 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
     if (obj)
         xmlXPathFreeObject(obj);

-    val = (long)((char *)cur - (char *)&base_address);
+    /*
+     * Try to provide stable ID for generated document:
+     *   - usually ID are computed to be placed on elements via attributes
+     *     so using the element as the node for the ID
+     *   - the cur->content should be a correct placeholder for this, we use
+     *     it to hold element node numbers in xmlXPathOrderDocElems to
+     *     speed up XPath too
+     *   - xsltCleanupIds() clean them up before handing the XSLT output
+     *     to the API client.
+     *   - other nodes types use the node address method but that should
+     *     not end up in resulting document ID
+     *   - we can enable this by default without risk of performance issues
+     *     only the one pass xsltCleanupIds() is added
+     */
+    if (cur->type == XML_ELEMENT_NODE) {
+        if (cur->content == NULL) {
+	    xsltTransformContextPtr tctxt;
+
+	    tctxt = xsltXPathGetTransformContext(ctxt);
+	    if (tctxt == NULL) {
+		val = (long)((char *)cur - (char *)&base_address);
+	    } else {
+		tctxt->nextid++;
+		val = tctxt->nextid;
+		cur->content = (void *) (val);
+	    }
+	} else {
+	    val = (long) cur->content;
+	}
+    } else {
+	val = (long)((char *)cur - (char *)&base_address);
+    }
+
     if (val >= 0) {
       sprintf((char *)str, "idp%ld", val);
     } else {
diff --git a/libxslt/functions.h b/libxslt/functions.h
index e0e0bf9..4a1e163 100644
--- a/libxslt/functions.h
+++ b/libxslt/functions.h
@@ -64,6 +64,13 @@ XSLTPUBFUN void XSLTCALL
 					 int nargs);

 /*
+ * Cleanup for ID generation
+ */
+XSLTPUBFUN int XSLTCALL
+	xsltCleanupIds			(xsltTransformContextPtr ctxt,
+					 xmlNodePtr root);
+
+/*
  * And the registration
  */

diff --git a/libxslt/transform.c b/libxslt/transform.c
index 24f9eb2..2bdf6bf 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -700,6 +700,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
     cur->traceCode = (unsigned long*) &xsltDefaultTrace;
     cur->xinclude = xsltGetXIncludeDefault();
     cur->keyInitLevel = 0;
+    cur->nextid = 0;

     return(cur);

@@ -6092,6 +6093,13 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
     if (root != NULL) {
         const xmlChar *doctype = NULL;

+        /*
+	 * cleanup ids which may have been saved in Elements content ptrs
+	 */
+	if (ctxt->nextid != 0) {
+	    xsltCleanupIds(ctxt, root);
+	}
+
         if ((root->ns != NULL) && (root->ns->prefix != NULL))
 	    doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name);
 	if (doctype == NULL)
diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h
index 95e8fe6..8eedae4 100644
--- a/libxslt/xsltInternals.h
+++ b/libxslt/xsltInternals.h
@@ -1786,6 +1786,8 @@ struct _xsltTransformContext {
     int funcLevel;      /* Needed to catch recursive functions issues */
     int maxTemplateDepth;
     int maxTemplateVars;
+
+    unsigned long nextid;/* for generating stable ids */
 };

 /**


code:
--- libXt-1.1.5/src/Intrinsic.c	2015-05-01 07:36:20.000000000 +0200
+++ Intrinsic.c	2016-12-12 00:42:16.567388450 +0100
@@ -1303,21 +1303,101 @@
     } else (void) strcpy(*rest, string);
 }

-/*
- * default path used if environment variable XFILESEARCHPATH
- * is not defined.  Also substitued for %D.
- * The exact value should be documented in the implementation
- * notes for any Xt implementation.
+
+
+/*
+   Return the default search path for the function
+   XtResolvePathname to use if XFILESEARCHPATH is
+   not defined.
+
+   It returns the combination the set of values which are the 6 "stems" below,
+   prepended with "/run/current-system/profile", and $GUIX_PROFILE and
+   "$HOME/.guix-profile"
+
+   These values provide the default paths where Guix/GuixSD  can expect
+   to find resources for installed packages.
  */
-static const char *implementation_default_path(void)
+static const char *guix_default_path(void)
 {
-#if defined(WIN32)
-    static char xfilesearchpath[] = "";
-
-    return xfilesearchpath;
-#else
-    return XFILESEARCHPATHDEFAULT;
-#endif
+  static const char *search_path_default_stem[] = {
+    "/lib/X11/%L/%T/%N%C%S",
+    "/lib/X11/%l/%T/%N%C%S",
+    "/lib/X11/%T/%N%C%S",
+    "/lib/X11/%L/%T/%N%S",
+    "/lib/X11/%l/%T/%N%S",
+    "/lib/X11/%T/%N%S"
+  };
+
+#define SIZEOF_STEMS  (strlen (search_path_default_stem[0])	\
+		       + strlen (search_path_default_stem[1])	\
+		       + strlen (search_path_default_stem[2])	\
+		       + strlen (search_path_default_stem[3])	\
+		       + strlen (search_path_default_stem[4])	\
+		       + strlen (search_path_default_stem[5]))
+
+
+  int i;
+  const char *current_profile = "/run/current-system/profile";
+  char *home = getenv ("HOME");
+  char *guix_profile = getenv ("GUIX_PROFILE");
+
+  size_t bytesAllocd = SIZEOF_STEMS + 1;
+
+  /* This function is evaluated multiple times and the calling
+     code assumes that it is idempotent. So we must not allow
+     (say) a changed environment variable to cause it to return
+     something different. */
+  static char *path = NULL;
+  if (path)
+    return path;
+
+  bytesAllocd += 6 * (1 + strlen (current_profile));
+
+  if (guix_profile != NULL)
+    {
+      bytesAllocd += SIZEOF_STEMS;
+      bytesAllocd += 6 * (1 + strlen (guix_profile));
+    }
+
+  if (home != NULL)
+    {
+      bytesAllocd += SIZEOF_STEMS;
+      bytesAllocd += 6 * (1 + strlen(home) + strlen ("/.guix-profile"));
+    }
+
+  path = XtMalloc(bytesAllocd);
+  if (path == NULL) _XtAllocError(NULL);
+
+  memset (path, 0, bytesAllocd);
+
+  for (i = 0 ; i < 6 ; ++i)
+    {
+      strcat (path, current_profile);
+      strcat (path, search_path_default_stem[i]);
+      strcat (path, ":");
+    }
+
+  if (guix_profile != NULL)
+    for (i = 0 ; i < 6 ; ++i)
+      {
+	strcat (path, guix_profile);
+	strcat (path, search_path_default_stem[i]);
+	strcat (path, ":");
+      }
+
+  if (home != NULL)
+    for (i = 0 ; i < 6 ; ++i)
+      {
+	strcat (path, home);
+	strcat (path, "/.guix-profile");
+	strcat (path, search_path_default_stem[i]);
+	strcat (path, ":");
+      }
+
+  /* Remove final : */
+  path[strlen(path) - 1] = '\0';
+
+  return path;
 }

@@ -1345,7 +1425,7 @@
 {
     XtPerDisplay pd;
     static const char *defaultPath = NULL;
-    const char *impl_default = implementation_default_path();
+    const char *impl_default = guix_default_path();
     int idef_len = strlen(impl_default);
     char *massagedPath;
     int bytesAllocd, bytesLeft;


code:
--- a/libziparchive/zip_writer.cc	2018-04-25 22:33:05.472674164 +0200
+++ b/libziparchive/zip_writer.cc	2018-04-25 22:33:21.296519518 +0200
@@ -22,6 +22,7 @@

 #include <sys/param.h>

+#include <cstring>
 #include <cassert>
 #include <cstdio>
 #include <memory>


code:
Patch copied from Debian:

https://anonscm.debian.org/cgit/pkg-games/lierolibre.git/tree/debian/patches/0001-Use-unaligned-access-define-over-checking-arch.patch?id=82910748906855f6e6bfe30b3f077e8c793ae424

From 396f19b6b7743d394307f70f0c0108419824437b Mon Sep 17 00:00:00 2001
From: Martin Erik Werner <martinerikwerner@gmail.com>
Date: Sun, 28 Jun 2015 16:31:34 +0200
Subject: [PATCH 1/3] Use unaligned access define over checking arch

This todo item seems like it done, and just needed implementing...
---
 io/encoding.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gvl/io/encoding.hpp b/src/gvl/io/encoding.hpp
index c491677..89bb612 100644
--- a/src/gvl/io/encoding.hpp
+++ b/src/gvl/io/encoding.hpp
@@ -374,7 +374,7 @@ struct octet_stream_writer
 		// inlining of the common case
 		if(std::size_t(end_ - cur_) >= len)
 		{
-#if GVL_X86 || GVL_X86_64 // TODO: A define that says whether unaligned access is allowed
+#if GVL_UNALIGNED_ACCESS
 			if(len < 64) // TODO: Tweak this limit
 			{
 				while(len > 4)
--
2.4.6


code:
Remove outdated license text. See COPYING and the description
at http://liero.be/ for more information.

--- a/data/LIEROENG.TXT
+++ b/data/LIEROENG.TXT
@@ -11,14 +11,6 @@
 -----------------------------------------------------------------------------

 GENERAL STUFF
-
-	Liero is freeware. What that means is that you don't have to pay
-	for it and using it has not been restricted in any way. You may
-        distribute it to anyone and anyhow WITHOUT ANY CHANGES MADE TO IT'S
-	CONTAINMENTS.
-
-	The source code of this game is not distributed freely (neither
-        commercially). So if you thought that maybe you could... forget it.

 	Liero is a wormgame with weapons for 2 players. The object of the
 	game is definately what you think it is. Liero is excellent for
--- a/data/LIERO.TXT
+++ b/data/LIERO.TXT
@@ -12,15 +12,6 @@

 YLEIST�

-        Liero on freeware, mik� tarkoittaa ett� sen k�yt�st� ei tarvitse
-        maksaa mit��n eik� k�ytt�� ole rajoitettu mitenk��n. Lieroa saa
-        kopioida kelle tahansa ja miten tahansa SIS�LT�� MITENK��N
-        MUUTTAMATTA.
-
-        Todettakoon t�ss� ett� Lieron l�hdekoodi ei ole vapaassa (sen
-        enenp�� kuin kaupallisessakaan) jakelussa. Joten jos ajattelit
-        ett�... niin j�t� ajatukset sikseen.
-
         Liero on kahden pelattava aseellinen matosimulaatiopeli. Pelin
         p��m��r�n� on ep�ilem�tt� se mit� luuletkin. Liero sopii
         erinomaisen hyvin aggressioiden purkuun ja kaverin rokitt�miseen


code:
Fix compatibility with newer libconfig.

Patch copied from upstream source repository:

https://gitlab.com/lierolibre/lierolibre/commit/b27e3604aa6bfbfcc50db1000b394d06c87ae2f2

diff --git a/src/common.cpp b/src/common.cpp
index 2d6ada5..4942b05 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -162,7 +162,7 @@ void Texts::loadFromCFG(std::string cfgFilePath)
 	const libconfig::Setting &sgmodes = texts["gameModes"];
 	for(int i = 0; i < 4; ++i)
 	{
-		gameModes[i] = (char const*)sgmodes["gameModes" + to_string(i)];
+		gameModes[i] = (char const*)sgmodes[("gameModes" + to_string(i)).c_str()];
 	}

 	const libconfig::Setting &sgmspec = texts["gameModeSpec"];
@@ -181,13 +181,13 @@ void Texts::loadFromCFG(std::string cfgFilePath)
 	const libconfig::Setting &swstates = texts["weapStates"];
 	for(int i = 0; i < 3; ++i)
 	{
-		 weapStates[i] = (char const*)swstates["weapStates" + to_string(i)];
+		 weapStates[i] = (char const*)swstates[("weapStates" + to_string(i)).c_str()];
 	}

 	const libconfig::Setting &sknames = texts["keyNames"];
 	for(int i = 1; i < 177; ++i) // First key starts at 1
 	{
-		keyNames[i] = (char const*)sknames["keyNames" + to_string(i)];
+		keyNames[i] = (char const*)sknames[("keyNames" + to_string(i)).c_str()];
 	}

 	selWeap = (char const*)texts["selWeap"];
@@ -315,8 +315,8 @@ void Common::loadPaletteFromCFG(std::string cfgFilePath)
 	const libconfig::Setting &scanim = palette["colorAnim"];
 	for(int i = 0; i < 4; ++i)
 	{
-		colorAnim[i].from = (int)scanim["colorAnim" + to_string(i) + "from"];
-		colorAnim[i].to = (int)scanim["colorAnim" + to_string(i) + "to"];
+		colorAnim[i].from = (int)scanim[("colorAnim" + to_string(i) + "from").c_str()];
+		colorAnim[i].to = (int)scanim[("colorAnim" + to_string(i) + "to").c_str()];
 	}
 }

@@ -383,7 +383,7 @@ void Common::loadMaterialsFromCFG(std::string cfgFilePath)

 	for(int i = 0; i < 256; ++i)
 	{
-		const libconfig::Setting &smflags = smaterials["flags" + to_string(i)];
+		const libconfig::Setting &smflags = smaterials[("flags" + to_string(i)).c_str()];
 		materials[i].flags = smflags;
 	}
 }
diff --git a/src/configCompat.cpp b/src/configCompat.cpp
index 1aeb262..a72c40f 100644
--- a/src/configCompat.cpp
+++ b/src/configCompat.cpp
@@ -160,19 +160,19 @@ void Common::loadConstantsFromCFGVer0(string cfgFilePath)
 	const Setting &vconstants = constants["Values"];
 	for(int i = 0; i < MaxC; ++i)
 	{
-		C[i] = (int)vconstants[valueConstantsNamesCFGVer0[i]];
+		C[i] = (int)vconstants[valueConstantsNamesCFGVer0[i].c_str()];
 	}

 	const Setting &sconstants = constants["Strings"];
 	for(int i = 0; i < MaxS; ++i)
 	{
-		S[i]= (char const*)sconstants[stringConstantsNamesCFGVer0[i]];
+		S[i]= (char const*)sconstants[stringConstantsNamesCFGVer0[i].c_str()];
 	}

 	const Setting &hconstants = constants["Hacks"];
 	for(int i = 0; i < MaxH; ++i)
 	{
-		H[i] = (bool)hconstants[hackConstantsNamesVer0[i]];
+		H[i] = (bool)hconstants[hackConstantsNamesVer0[i].c_str()];
 	}
 }

diff --git a/src/configHelper.cpp b/src/configHelper.cpp
index fcd1f3f..a63bddc 100644
--- a/src/configHelper.cpp
+++ b/src/configHelper.cpp
@@ -54,15 +54,11 @@ template Uint8 ConfigHelper::getValue<Uint8, const Setting, int>(const Setting &

 template Uint8 ConfigHelper::getValue<Uint8, const Setting, char const*>(const Setting &node, char const* index);

-template Uint8 ConfigHelper::getValue<Uint8, const Setting, string>(const Setting &node, string index);
-
 // Non-const
 template Uint8 ConfigHelper::getValue<Uint8, Setting, int>(Setting &node, int index);

 template Uint8 ConfigHelper::getValue<Uint8, Setting, char const*>(Setting &node, char const* index);

-template Uint8 ConfigHelper::getValue<Uint8, Setting, string>(Setting &node, string index);
-

 // Since we still need specialisation per value type (Setting::Type),
 // no need to templateify these
@@ -72,7 +68,7 @@ void ConfigHelper::put(Setting &node, string variable, string value)
 	{
 		node.add(variable, Setting::TypeString) = value;
 	} else {
-		Setting &var = node[variable];
+		Setting &var = node[variable.c_str()];
 		var = value;
 	}
 }
@@ -83,7 +79,7 @@ void ConfigHelper::put(Setting &node, string variable, int value)
 	{
 		node.add(variable, Setting::TypeInt) = value;
 	} else {
-		Setting &var = node[variable];
+		Setting &var = node[variable.c_str()];
 		var = value;
 	}
 }
@@ -94,7 +90,7 @@ void ConfigHelper::put(Setting &node, string variable, Uint8 value)
 	{
 		node.add(variable, Setting::TypeInt) = value;
 	} else {
-		Setting &var = node[variable];
+		Setting &var = node[variable.c_str()];
 		var = value;
 	}
 }
@@ -105,7 +101,7 @@ void ConfigHelper::put(Setting &node, string variable, bool value)
 	{
 		node.add(variable, Setting::TypeBoolean) = value;
 	} else {
-		Setting &var = node[variable];
+		Setting &var = node[variable.c_str()];
 		var = value;
 	}
 }
@@ -135,6 +131,6 @@ Setting& ConfigHelper::getSubgroup(Setting &node, string groupName)
 	{
 		node.add(groupName, Setting::TypeGroup);
 	}
-	return node[groupName];
+	return node[groupName.c_str()];
 }

diff --git a/src/constants.cpp b/src/constants.cpp
index 7fced6a..cf7bbfc 100644
--- a/src/constants.cpp
+++ b/src/constants.cpp
@@ -523,19 +523,19 @@ void Common::loadConstantsFromCFG(std::string cfgFilePath)
 	const libconfig::Setting &vconstants = constants["Values"];
 	for(int i = 0; i < MaxC; ++i)
 	{
-		C[i] = (int)vconstants[valueConstantsNames[i]];
+		C[i] = (int)vconstants[valueConstantsNames[i].c_str()];
 	}

 	const libconfig::Setting &sconstants = constants["Strings"];
 	for(int i = 0; i < MaxS; ++i)
 	{
-		S[i]= (char const*)sconstants[stringConstantsNames[i]];
+		S[i]= (char const*)sconstants[stringConstantsNames[i].c_str()];
 	}

 	const libconfig::Setting &hconstants = constants["Hacks"];
 	for(int i = 0; i < MaxH; ++i)
 	{
-		H[i] = (bool)hconstants[hackConstantsNames[i]];
+		H[i] = (bool)hconstants[hackConstantsNames[i].c_str()];
 	}
 }

diff --git a/src/gfx/palette.cpp b/src/gfx/palette.cpp
index 3fd08c4..3d3bf22 100644
--- a/src/gfx/palette.cpp
+++ b/src/gfx/palette.cpp
@@ -124,9 +124,9 @@ void Palette::readFromCFG(std::string cfgFilePath)

 	for(int i = 0; i < 256; ++i)
 	{
-		entries[i].r = cfgHelp.getValue<Uint8>(spentries, "entries" + to_string(i) + "r");
-		entries[i].g = cfgHelp.getValue<Uint8>(spentries, "entries" + to_string(i) + "g");
-		entries[i].b = cfgHelp.getValue<Uint8>(spentries, "entries" + to_string(i) + "b");
+		entries[i].r = cfgHelp.getValue<Uint8>(spentries, ("entries" + to_string(i) + "r").c_str());
+		entries[i].g = cfgHelp.getValue<Uint8>(spentries, ("entries" + to_string(i) + "g").c_str());
+		entries[i].b = cfgHelp.getValue<Uint8>(spentries, ("entries" + to_string(i) + "b").c_str());
 	}
 }


code:
Copied from Debian:

https://anonscm.debian.org/cgit/pkg-games/lierolibre.git/tree/debian/patches/0003-Remove-unknown-arch-warning.patch?id=82910748906855f6e6bfe30b3f077e8c793ae424

From a9592533eeabed075b13d11c64f63f503dc13343 Mon Sep 17 00:00:00 2001
From: Martin Erik Werner <martinerikwerner@gmail.com>
Date: Sun, 28 Jun 2015 19:31:30 +0200
Subject: [PATCH 3/3] Remove unknown arch warning

The warning was just excessivley spammy, remove it.
---
 support/platform.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/gvl/support/platform.h b/src/gvl/support/platform.h
index 1857b7c..ff6a7d2 100644
--- a/src/gvl/support/platform.h
+++ b/src/gvl/support/platform.h
@@ -87,8 +87,6 @@
 #  define GVL_X86_64 1
 # elif defined(__i386__) || defined(_M_IX86) || defined(i386) || defined(i486) || defined(intel) || defined(x86) || defined(i86pc)
 #  define GVL_X86 1
-# else
-#  warning "Unknown architecture, please add it"
 # endif
 #endif

--
2.4.6


code:
Copied from Debian:

https://anonscm.debian.org/cgit/pkg-games/lierolibre.git/tree/debian/patches/0001-Use-unaligned-access-define-over-checking-arch.patch?id=82910748906855f6e6bfe30b3f077e8c793ae424

From a70691fb003cae1a33f06d682269285f9baa2dd9 Mon Sep 17 00:00:00 2001
From: Martin Erik Werner <martinerikwerner@gmail.com>
Date: Sun, 28 Jun 2015 19:00:23 +0200
Subject: [PATCH 2/3] At least try building for other archs than x86*

Allow attempting to build for other architectures than x86 and x86_64,
whether or not the build will succeed or produce sane output is another
question... It emits plenty of warnings about it now though...

Configuration of the FPU controller is disabled on all but x86*, and the
uninformed hope and prayer is that defaults will be fine without messing
with them.
---
 math/ieee.cpp      | 2 ++
 support/platform.h | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gvl/math/ieee.cpp b/src/gvl/math/ieee.cpp
index 8b740d4..e0803d2 100644
--- a/src/gvl/math/ieee.cpp
+++ b/src/gvl/math/ieee.cpp
@@ -54,6 +54,8 @@ void gvl_init_ieee()
 {
 #if GVL_MSVCPP
 // Nothing needs to be done, TODO: we should however check that the x87 state is right
+#elif !GVL_X86 && !GVL_X86_64
+// No idea what to do, but run with defaults and pray it doesn't mess things up
 #elif GVL_GCC && GVL_WIN32
     unsigned int const flags = _RC_NEAR | _PC_53 | _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW | _EM_INEXACT;
     _control87(flags, _MCW_EM | _MCW_PC | _MCW_RC);
diff --git a/src/gvl/support/platform.h b/src/gvl/support/platform.h
index 86dcaa6..1857b7c 100644
--- a/src/gvl/support/platform.h
+++ b/src/gvl/support/platform.h
@@ -88,12 +88,12 @@
 # elif defined(__i386__) || defined(_M_IX86) || defined(i386) || defined(i486) || defined(intel) || defined(x86) || defined(i86pc)
 #  define GVL_X86 1
 # else
-#  error "Unknown architecture, please add it"
+#  warning "Unknown architecture, please add it"
 # endif
 #endif

 #if !GVL_LITTLE_ENDIAN && !GVL_BIG_ENDIAN
-# if GVL_X86 || GVL_X86_64
+# if GVL_X86 || GVL_X86_64 || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN
 #  define GVL_LITTLE_ENDIAN 1
 # else
 #  define GVL_BIG_ENDIAN 1
--
2.4.6


code:
On systems without 'setfsuid', use 'setreuid' instead.

The patch originates from the Debian project for GNU/Hurd.
Authors: Steve Langasek <vorlon@debian.org>
Upstream status: A ticket was opened to request apply the patch,
ticket: 'https://fedorahosted.org/linux-pam/ticket/64'.

--- Linux-PAM-1.2.1/libpam/pam_modutil_priv.c	2015-03-24 06:02:32.000000000 -0600
+++ pam_modutil_priv-mod.c	2016-09-20 13:36:53.150663205 -0500
@@ -14,7 +14,9 @@
 #include <syslog.h>
 #include <pwd.h>
 #include <grp.h>
+#ifdef HAVE_SYS_FSUID_H
 #include <sys/fsuid.h>
+#endif /* HAVE_SYS_FSUID_H */

 /*
  * Two setfsuid() calls in a row are necessary to check
@@ -22,17 +24,55 @@
  */
 static int change_uid(uid_t uid, uid_t *save)
 {
+#ifdef HAVE_SYS_FSUID_H
 	uid_t tmp = setfsuid(uid);
 	if (save)
 		*save = tmp;
 	return (uid_t) setfsuid(uid) == uid ? 0 : -1;
+#else
+	uid_t euid = geteuid();
+	uid_t ruid = getuid();
+	if (save)
+		*save = ruid;
+	if (ruid == uid && uid != 0)
+		if (setreuid(euid, uid))
+			return -1;
+	else {
+		setreuid(0, -1);
+		if (setreuid(-1, uid)) {
+			setreuid(-1, 0);
+			setreuid(0, -1);
+			if (setreuid(-1, uid))
+				return -1;
+		}
+	}
+#endif
 }
 static int change_gid(gid_t gid, gid_t *save)
 {
+#ifdef HAVE_SYS_FSUID_H
 	gid_t tmp = setfsgid(gid);
 	if (save)
 		*save = tmp;
 	return (gid_t) setfsgid(gid) == gid ? 0 : -1;
+#else
+	gid_t egid = getegid();
+	gid_t rgid = getgid();
+	if (save)
+		*save = rgid;
+	if (rgid == gid)
+		if (setregid(egid, gid))
+			return -1;
+	else {
+		setregid(0, -1);
+		if (setregid(-1, gid)) {
+			setregid(-1, 0);
+			setregid(0, -1);
+			if (setregid(-1, gid))
+				return -1;
+		}
+	}
+#endif
 }

 static int cleanup(struct pam_modutil_privs *p)


code:
Do not try to create $localstatedir as we cannot do this when it is /var.

--- lirc-0.9.2a/daemons/Makefile.in
+++ lirc-0.9.2a/daemons/Makefile.in
@@ -790,9 +790,6 @@
 	uninstall-local uninstall-sbinPROGRAMS

-install-exec-local:
-	test -d  $(DESTDIR)$(varrundir)/$(PACKAGE) \
-		 || mkdir -p $(DESTDIR)$(varrundir)/$(PACKAGE)
 uninstall-local:
 	-$(RM) $(DESTDIR)$(varrundir)/$(PACKAGE)/lircd


code:
This patch was downloaded from https://sft.its.cern.ch/jira/browse/ROOT-7047.
It fixes the build of clang 3.5 with GCC 5.  File paths have been adjusted.

From 00f3ed6eee41da871799ad0fd19153c7682d61fe Mon Sep 17 00:00:00 2001
From: Alexander Klimov <alserkli@inbox.ru>
Date: Mon, 26 Jan 2015 18:45:23 +0200
Subject: [PATCH] [ADT/IntrusiveRefCntPtr] Give friend access to
 IntrusiveRefCntPtr<X> so the relevant move constructor can
 access 'Obj'.

From LLVM upstream:
Author: Argyrios Kyrtzidis <akyrtzi@gmail.com>
Date:   Tue Sep 23 06:06:43 2014 +0000
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218295 91177308-0d34-0410-b5e6-96231b3b80d8
---
 interpreter/llvm/src/include/llvm/ADT/IntrusiveRefCntPtr.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h
index f9df378..c859c98 100644
--- a/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ b/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -197,6 +197,9 @@ public:
   private:
     void retain() { if (Obj) IntrusiveRefCntPtrInfo<T>::retain(Obj); }
     void release() { if (Obj) IntrusiveRefCntPtrInfo<T>::release(Obj); }
+
+    template <typename X>
+    friend class IntrusiveRefCntPtr;
   };

   template<class T, class U>
--
1.7.10.4


code:
This patch to LLVM is required by the developers of the Extempore language.
The following explanation was posted to the extemporelang@googlegroups.com
mailing list:

"There is an assumption in the parser that all definitions occur within the
same compilation unit - i.e. the parser has local state about what has been
parsed in this unit of work.  Extempore obviously does lots of little units
rather than one big unit and this causes problems for named types that were
defined in another unit - which they always are.  The patch simply checks the
current module to see if the type has been previously defined, and intervenes
appropriately if it has."

Message-ID: <CAOjrPOqoreXuZo4ZpDBvHE7M_tgAR_V8Txq5JFjh1HnGRn2EsA@mail.gmail.com>

--- llvm-3.7.1.src/include/llvm/MC/MCSectionCOFF.h	2015-04-11 12:11:45.000000000 +1000
+++ llvm-3.7.1.src/include/llvm/MC/MCSectionCOFF.h	2015-09-14 09:22:56.000000000 +1000
@@ -16,7 +16,6 @@

 #include "llvm/ADT/StringRef.h"
 #include "llvm/MC/MCSection.h"
-#include "llvm/Support/COFF.h"

 namespace llvm {
 class MCSymbol;

--- llvm-3.7.1.src/lib/AsmParser/LLParser.cpp	2015-07-11 20:30:36.000000000 +1000
+++ llvm-3.7.1.src/lib/AsmParser/LLParser.cpp	2015-09-14 09:20:57.000000000 +1000
@@ -1754,8 +1754,14 @@
     // If the type hasn't been defined yet, create a forward definition and
     // remember where that forward def'n was seen (in case it never is defined).
     if (!Entry.first) {
-      Entry.first = StructType::create(Context, Lex.getStrVal());
-      Entry.second = Lex.getLoc();
+      // this here for extempore
+      if (M->getTypeByName(Lex.getStrVal())) {
+        Entry.first = M->getTypeByName(Lex.getStrVal());
+        Entry.second = SMLoc();
+      } else {
+        Entry.first = StructType::create(Context, Lex.getStrVal());
+        Entry.second = Lex.getLoc();
+      }
     }
     Result = Entry.first;
     Lex.Lex();

--- llvm-3.7.1.src/lib/CodeGen/TargetLoweringObjectFileImpl.cpp	2015-07-01 05:10:31.000000000 +1000
+++ llvm-3.7.1.src/lib/CodeGen/TargetLoweringObjectFileImpl.cpp	2015-09-14 09:23:40.000000000 +1000
@@ -32,6 +32,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbolELF.h"
 #include "llvm/MC/MCValue.h"
+#include "llvm/Support/COFF.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"

--- llvm-3.7.1.src/lib/ExecutionEngine/MCJIT/MCJIT.cpp	2015-07-31 02:31:16.000000000 +1000
+++ llvm-3.7.1.src/lib/ExecutionEngine/MCJIT/MCJIT.cpp	2015-09-14 09:21:28.000000000 +1000
@@ -524,6 +524,17 @@
         rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));
         return rv;
       }
+      if (FTy->getNumParams() == 1 &&
+          RetTy->isVoidTy() &&
+          FTy->getParamType(0)->isPointerTy()) {
+        GenericValue rv;
+        //void (*PF)(char *) = (void(*)(char *))(intptr_t)FPtr;
+        //printf("are symbols available: %d\n",isSymbolSearchingDisabled());
+        void (*PF)(char *) = (void(*)(char *))FPtr;
+        char* mzone = (char*) GVTOP(ArgValues[0]);
+        PF(mzone);
+        return rv;
+      }
       break;
     }
   }

--- llvm-3.7.1.src/lib/MC/MCContext.cpp	2015-06-23 21:31:32.000000000 +1000
+++ llvm-3.7.1.src/lib/MC/MCContext.cpp	2015-09-14 09:24:01.000000000 +1000
@@ -23,6 +23,7 @@
 #include "llvm/MC/MCSymbolCOFF.h"
 #include "llvm/MC/MCSymbolELF.h"
 #include "llvm/MC/MCSymbolMachO.h"
+#include "llvm/Support/COFF.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"

--- llvm-3.7.1.src/lib/MC/MCObjectFileInfo.cpp	2015-06-25 10:28:42.000000000 +1000
+++ llvm-3.7.1.src/lib/MC/MCObjectFileInfo.cpp	2015-09-14 09:24:17.000000000 +1000
@@ -16,6 +16,7 @@
 #include "llvm/MC/MCSectionCOFF.h"
 #include "llvm/MC/MCSectionELF.h"
 #include "llvm/MC/MCSectionMachO.h"
+#include "llvm/Support/COFF.h"
 using namespace llvm;

 static bool useCompactUnwind(const Triple &T) {

--- llvm-3.7.1.src/lib/MC/MCSectionCOFF.cpp	2015-06-09 10:31:39.000000000 +1000
+++ llvm-3.7.1.src/lib/MC/MCSectionCOFF.cpp	2015-09-14 09:24:25.000000000 +1000
@@ -11,6 +11,7 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/COFF.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;

--- llvm-3.7.1.src/lib/Target/X86/X86TargetObjectFile.cpp	2015-06-27 04:55:48.000000000 +1000
+++ llvm-3.7.1.src/lib/Target/X86/X86TargetObjectFile.cpp	2015-09-14 09:25:03.000000000 +1000
@@ -16,6 +16,7 @@
 #include "llvm/MC/MCSectionCOFF.h"
 #include "llvm/MC/MCSectionELF.h"
 #include "llvm/MC/MCValue.h"
+#include "llvm/Support/COFF.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Target/TargetLowering.h"


code:
fancontrol: Deal with moving hwmon attributes

Several kernel drivers have already moved their attributes from the
hardware device to the hwmon class device, and others will follow.
Teach fancontrol about this possibility and let it adjust the attribute
paths transparently.

Patch by Jean Delvare <khali@linux-fr.org>.
See <http://www.lm-sensors.org/changeset/6216>.

--- lm-sensors/prog/pwm/fancontrol	(revision 6172)
+++ lm-sensors/prog/pwm/fancontrol	(revision 6216)
@@ -207,4 +207,63 @@
 }

+function FixupDeviceFiles
+{
+	local DEVICE="$1"
+	local fcvcount pwmo tsen fan
+
+	let fcvcount=0
+	while (( $fcvcount < ${#AFCPWM[@]} )) # go through all pwm outputs
+	do
+		pwmo=${AFCPWM[$fcvcount]}
+		AFCPWM[$fcvcount]=${pwmo//$DEVICE\/device/$DEVICE}
+		if [ "${AFCPWM[$fcvcount]}" != "$pwmo" ]
+		then
+			echo "Adjusing $pwmo -> ${AFCPWM[$fcvcount]}"
+		fi
+		let fcvcount=$fcvcount+1
+	done
+
+	let fcvcount=0
+	while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs
+	do
+		tsen=${AFCTEMP[$fcvcount]}
+		AFCTEMP[$fcvcount]=${tsen//$DEVICE\/device/$DEVICE}
+		if [ "${AFCTEMP[$fcvcount]}" != "$tsen" ]
+		then
+			echo "Adjusing $tsen -> ${AFCTEMP[$fcvcount]}"
+		fi
+		let fcvcount=$fcvcount+1
+	done
+
+	let fcvcount=0
+	while (( $fcvcount < ${#AFCFAN[@]} )) # go through all fan inputs
+	do
+		fan=${AFCFAN[$fcvcount]}
+		AFCFAN[$fcvcount]=${fan//$DEVICE\/device/$DEVICE}
+		if [ "${AFCFAN[$fcvcount]}" != "$fan" ]
+		then
+			echo "Adjusing $fan -> ${AFCFAN[$fcvcount]}"
+		fi
+		let fcvcount=$fcvcount+1
+	done
+}
+
+# Some drivers moved their attributes from hard device to class device
+function FixupFiles
+{
+	local DEVPATH="$1"
+	local entry device
+
+	for entry in $DEVPATH
+	do
+		device=`echo "$entry" | sed -e 's/=[^=]*$//'`
+
+		if [ -e "$device/name" ]
+		then
+			FixupDeviceFiles "$device"
+		fi
+	done
+}
+
 # Check that all referenced sysfs files exist
 function CheckFiles
@@ -306,4 +365,8 @@
 	echo "Configuration appears to be outdated, please run pwmconfig again" >&2
 	exit 1
+fi
+if [ "$DIR" = "/sys/class/hwmon" ]
+then
+	FixupFiles "$DEVPATH"
 fi
 CheckFiles || exit 1


code:
From 38386bd482c0a8102a79958cb3eddcb97a167ca3 Mon Sep 17 00:00:00 2001
From: Con Kolivas <kernel@kolivas.org>
Date: Fri, 9 Mar 2018 17:39:40 +1100
Subject: [PATCH] CVE-2017-8842 Fix divide-by-zero in bufRead::get

---
 libzpaq/libzpaq.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libzpaq/libzpaq.h b/libzpaq/libzpaq.h
index 93387da..cbe211d 100644
--- a/libzpaq/libzpaq.h
+++ b/libzpaq/libzpaq.h
@@ -465,7 +465,8 @@ struct bufRead: public libzpaq::Reader {

 	int get() {
 		if (progress && !(*s_len % 128)) {
-			int pct = (total_len - *s_len) * 100 / total_len;
+			int pct = (total_len > 0) ?
+				(total_len - *s_len) * 100 / total_len : 100;

 			if (pct / 10 != *last_pct / 10) {
 				int i;


code:
From: Enrico Tassi <gareuselesinge@debian.org>
Date: Tue, 26 Aug 2014 16:20:55 +0200
Subject: Fix stack overflow in vararg functions

---
 src/ldo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ldo.c b/src/ldo.c
index d1bf786..30333bf 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -274,7 +274,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
     CallInfo *ci;
     StkId st, base;
     Proto *p = cl->p;
-    luaD_checkstack(L, p->maxstacksize);
+    luaD_checkstack(L, p->maxstacksize + p->numparams);
     func = restorestack(L, funcr);
       base = func + 1;


code:
This applies to Lua 5.2 and 5.3.

From 7a1b4e0829124976878ca2765a8e546667a92ceb Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Fri, 30 Oct 2015 19:11:31 -0400
Subject: [PATCH] apply existing non-executable library patch and install
 libraries as executable

---
 Makefile     | 6 +++---
 src/Makefile | 8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 1aea8e6..bfcfed9 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,7 @@ INTERPRETER= lua
 COMPILER= luac
 TO_BIN= $(INTERPRETER) $(COMPILER)
 TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.a liblua.so liblua.so.${V}
 TO_PC=  lua-$(V).pc
 TO_MAN= lua.1 luac.1

@@ -56,7 +56,7 @@ R= $V.3
 all:	$(PLAT)

 $(PLATS):
-	cd src && $(MAKE) $@
+	cd src && $(MAKE) $@ V=$(V) R=$(R)

 clean:
 	cd src && $(MAKE) $@
@@ -69,7 +69,7 @@ install: dummy $(TO_PC)
 	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_PC) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
 	cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
 	cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
-	cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
+	cd src && $(INSTALL_EXEC) $(TO_LIB) $(INSTALL_LIB)
 	cd src && $(INSTALL_DATA) ../$(TO_PC) $(INSTALL_PC)
 	cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)

diff --git a/src/Makefile b/src/Makefile
index 7b4b2b7..c86476e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -29,6 +29,7 @@ MYOBJS=
 PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris

 LUA_A=	liblua.a
+LUA_SO= liblua.so
 CORE_O=	lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
 	lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
 	ltm.o lundump.o lvm.o lzio.o
@@ -43,7 +44,7 @@ LUAC_T=	luac
 LUAC_O=	luac.o

 ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
 ALL_A= $(LUA_A)

 # Targets start here.
@@ -55,6 +56,11 @@ o:	$(ALL_O)

 a:	$(ALL_A)

+$(LUA_SO): $(CORE_O) $(LIB_O)
+	$(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
+	ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
+	ln -sf $(LUA_SO).$(R) $(LUA_SO)
+
 $(LUA_A): $(BASE_O)
 	$(AR) $@ $(BASE_O)
 	$(RANLIB) $@
--
2.6.1


code:
Enables generating Lua's pkg-config file.

http://lua-users.org/lists/lua-l/2015-03/msg00338.html

--- a/Makefile	2014-10-30 00:14:41.000000000 +0100
+++ b/Makefile	2015-03-26 18:54:37.678374827 +0100
@@ -14,6 +14,7 @@
 INSTALL_BIN= $(INSTALL_TOP)/bin
 INSTALL_INC= $(INSTALL_TOP)/include
 INSTALL_LIB= $(INSTALL_TOP)/lib
+INSTALL_PC= $(INSTALL_LIB)/pkgconfig
 INSTALL_MAN= $(INSTALL_TOP)/man/man1
 INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
 INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
@@ -39,9 +40,12 @@
 PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris

 # What to install.
-TO_BIN= lua luac
+INTERPRETER= lua
+COMPILER= luac
+TO_BIN= $(INTERPRETER) $(COMPILER)
 TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
 TO_LIB= liblua.a
+TO_PC=  lua-$(V).pc
 TO_MAN= lua.1 luac.1

 # Lua version and release.
@@ -51,23 +55,29 @@
 # Targets start here.
 all:	$(PLAT)

-$(PLATS) clean:
+$(PLATS):
 	cd src && $(MAKE) $@

+clean:
+	cd src && $(MAKE) $@
+	$(RM) $(TO_PC)
+
 test:	dummy
 	src/lua -v

-install: dummy
-	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
+install: dummy $(TO_PC)
+	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_PC) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
 	cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
 	cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
 	cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
+	cd src && $(INSTALL_DATA) ../$(TO_PC) $(INSTALL_PC)
 	cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)

 uninstall:
 	cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
 	cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC)
 	cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB)
+	cd src && cd $(INSTALL_PC)  && $(RM) $(TO_PC)
 	cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN)

 local:
@@ -90,11 +100,13 @@
 	@echo "TO_BIN= $(TO_BIN)"
 	@echo "TO_INC= $(TO_INC)"
 	@echo "TO_LIB= $(TO_LIB)"
+	@echo "TO_PC= $(TO_PC)"
 	@echo "TO_MAN= $(TO_MAN)"
 	@echo "INSTALL_TOP= $(INSTALL_TOP)"
 	@echo "INSTALL_BIN= $(INSTALL_BIN)"
 	@echo "INSTALL_INC= $(INSTALL_INC)"
 	@echo "INSTALL_LIB= $(INSTALL_LIB)"
+	@echo "INSTALL_PC= $(INSTALL_PC)"
 	@echo "INSTALL_MAN= $(INSTALL_MAN)"
 	@echo "INSTALL_LMOD= $(INSTALL_LMOD)"
 	@echo "INSTALL_CMOD= $(INSTALL_CMOD)"
@@ -103,12 +115,28 @@

 # echo pkg-config data
 pc:
-	@echo "version=$R"
-	@echo "prefix=$(INSTALL_TOP)"
-	@echo "libdir=$(INSTALL_LIB)"
-	@echo "includedir=$(INSTALL_INC)"
+	@echo 'prefix=$(INSTALL_TOP)'
+	@echo 'libdir=$(INSTALL_LIB)'
+	@echo 'includedir=$(INSTALL_INC)'
+	@echo 'bindir=$(INSTALL_BIN)'
+	@echo
+	@echo 'INSTALL_LMOD=$(INSTALL_LMOD)'
+	@echo 'INSTALL_CMOD=$(INSTALL_CMOD)'
+	@echo 'INTERPRETER=$${bindir}/$(INTERPRETER)'
+	@echo 'COMPILER=$${bindir}/$(COMPILER)'
+	@echo
+	@echo 'Name: Lua'
+	@echo 'Description: A powerful, fast, lightweight, embeddable scripting language'
+	@echo 'Version: $(R)'
+	@echo
+	@echo 'Libs: -L$${libdir} -llua -lm'
+	@echo 'Cflags: -I$${includedir}'
+
+pkg-config: $(TO_PC)
+$(TO_PC):
+	@$(MAKE) -s pc > $@

 # list targets that do not create files (but not all makes understand .PHONY)
-.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho
+.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho pkg-config

 # (end of Makefile)


code:
Patch the two Makefile to also create liblua.so
Original patch by Allan McRae <allan@archlinux.org>
for Archlinux

diff -ruN lua-5.1.5/Makefile lua-5.1.5-new/Makefile
--- lua-5.1.5/Makefile	2012-02-10 10:50:23.000000000 +0100
+++ lua-5.1.5-new/Makefile	2014-09-10 20:17:28.913951433 +0200
@@ -43,7 +43,7 @@
 # What to install.
 TO_BIN= lua luac
 TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.a liblua.so liblua.so.${V}
 TO_MAN= lua.1 luac.1

 # Lua version and release.
@@ -53,7 +53,7 @@
 all:	$(PLAT)

 $(PLATS) clean:
-	cd src && $(MAKE) $@
+	cd src && $(MAKE) $@ V=$(V) R=$(R)

 test:	dummy
 	src/lua test/hello.lua
diff -ruN lua-5.1.5/src/Makefile lua-5.1.5-new/src/Makefile
--- lua-5.1.5/src/Makefile	2012-02-13 21:41:22.000000000 +0100
+++ lua-5.1.5-new/src/Makefile	2014-09-10 20:16:09.982952152 +0200
@@ -8,7 +8,7 @@
 PLAT= none

 CC= gcc
-CFLAGS= -O2 -Wall $(MYCFLAGS)
+CFLAGS= -O2 -Wall $(MYCFLAGS) -fPIC
 AR= ar rcu
 RANLIB= ranlib
 RM= rm -f
@@ -34,9 +34,10 @@

 LUAC_T=	luac
 LUAC_O=	luac.o print.o
+LUA_SO= liblua.so

 ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
 ALL_A= $(LUA_A)

 default: $(PLAT)
@@ -57,6 +58,13 @@
 $(LUAC_T): $(LUAC_O) $(LUA_A)
 	$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)

+$(LUA_SO): $(CORE_O) $(LIB_O)
+	$(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
+	ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
+	ln -sf $(LUA_SO).$(R) $(LUA_SO)
+
+
+
 clean:
 	$(RM) $(ALL_T) $(ALL_O)


code:
Enables generating Lua's pkg-config file.

http://lua-users.org/lists/lua-l/2015-03/msg00338.html

--- a/Makefile	2016-08-16 19:44:27.363614964 +0200
+++ b/Makefile	2016-08-16 19:49:22.623070005 +0200
@@ -13,6 +13,7 @@
 INSTALL_BIN= $(INSTALL_TOP)/bin
 INSTALL_INC= $(INSTALL_TOP)/include
 INSTALL_LIB= $(INSTALL_TOP)/lib
+INSTALL_PC= $(INSTALL_LIB)/pkgconfig
 INSTALL_MAN= $(INSTALL_TOP)/man/man1
 #
 # You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
@@ -41,9 +42,12 @@
 PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris

 # What to install.
-TO_BIN= lua luac
+INTERPRETER= lua
+COMPILER= luac
+TO_BIN= $(INTERPRETER) $(COMPILER)
 TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
 TO_LIB= liblua.a liblua.so liblua.so.${V}
+TO_PC= lua-$(V).pc
 TO_MAN= lua.1 luac.1

 # Lua version and release.
@@ -52,17 +56,22 @@

 all:	$(PLAT)

-$(PLATS) clean:
+$(PLATS):
 	cd src && $(MAKE) $@ V=$(V) R=$(R)

+clean:
+	cd src && $(MAKE) $@
+	$(RM) $(TO_PC)
+
 test:	dummy
 	src/lua test/hello.lua

-install: dummy
-	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
+install: dummy $(TO_PC)
+	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_PC) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
 	cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
 	cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
 	cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
+	cd src && $(INSTALL_DATA) ../$(TO_PC) $(INSTALL_PC)
 	cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)

 ranlib:
@@ -95,6 +104,7 @@
 	@echo "INSTALL_BIN = $(INSTALL_BIN)"
 	@echo "INSTALL_INC = $(INSTALL_INC)"
 	@echo "INSTALL_LIB = $(INSTALL_LIB)"
+	@echo "INSTALL_PC = $(INSTALL_PC)"
 	@echo "INSTALL_MAN = $(INSTALL_MAN)"
 	@echo "INSTALL_LMOD = $(INSTALL_LMOD)"
 	@echo "INSTALL_CMOD = $(INSTALL_CMOD)"
@@ -111,6 +121,7 @@
 	@echo "TO_BIN = $(TO_BIN)"
 	@echo "TO_INC = $(TO_INC)"
 	@echo "TO_LIB = $(TO_LIB)"
+	@echo "TO_PC = $(TO_PC)"
 	@echo "TO_MAN = $(TO_MAN)"

 # echo config parameters as Lua code
@@ -122,7 +133,29 @@
 	@$(MAKE) echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/'
 	@echo "-- EOF"

+pc:
+	@echo 'prefix=$(INSTALL_TOP)'
+	@echo 'libdir=$(INSTALL_LIB)'
+	@echo 'includedir=$(INSTALL_INC)'
+	@echo 'bindir=$(INSTALL_BIN)'
+	@echo
+	@echo 'INSTALL_LMOD=$(INSTALL_LMOD)'
+	@echo 'INSTALL_CMOD=$(INSTALL_CMOD)'
+	@echo 'INTERPRETER=$${bindir}/$(INTERPRETER)'
+	@echo 'COMPILER=$${bindir}/$(COMPILER)'
+	@echo
+	@echo 'Name: Lua'
+	@echo 'Description: A powerful, fast, lightweight, embeddable scripting language'
+	@echo 'Version: $(R)'
+	@echo
+	@echo 'Libs: -L$${libdir} -llua -lm'
+	@echo 'Cflags: -I$${includedir}'
+
+pkg-config: $(TO_PC)
+$(TO_PC):
+	@$(MAKE) -s pc > $@
+
 # list targets that do not create files (but not all makes understand .PHONY)
-.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho
+.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho pkg-config

 # (end of Makefile)


code:
From 629200f48e18dc1a3a5229739748bad0e2a6a0a2 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Tom=C3=A1=C5=A1=20=C4=8Cech?= <sleep_walker@suse.cz>
Date: Wed, 4 Feb 2015 11:37:16 +0100
Subject: [PATCH] Do not silently and prematurely end install when ldconfig is
 missing

---
 Makefile | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 343ecb5..4667146 100644
--- a/Makefile
+++ b/Makefile
@@ -112,9 +112,10 @@ install: $(INSTALL_DEP)
 	$(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
 	cd src && test -f $(FILE_SO) && \
 	  $(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \
-	  $(LDCONFIG) $(INSTALL_LIB) && \
-	  $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \
-	  $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || :
+	  ( $(LDCONFIG) $(INSTALL_LIB) ; \
+	    $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \
+	    $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || : \
+	  )
 	cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN)
 	cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \
 	  $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \
--
2.2.2


code:
See https://bugs.freedesktop.org/show_bug.cgi?id=47792;
should become obsolete with the next release.

diff -u luit-1.1.1.orig/sys.c luit-1.1.1/sys.c
--- luit-1.1.1.orig/sys.c	2012-03-23 05:23:07.000000000 +0100
+++ luit-1.1.1/sys.c	2013-11-27 22:45:53.000000000 +0100
@@ -20,6 +20,8 @@
 THE SOFTWARE.
 */

+#define _XOPEN_SOURCE 600
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif


code:
Allow the 'QtPrinter' header to be found, as described
at <https://github.com/LuminanceHDR/LuminanceHDR/issues/11>.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fbad8a2..8379c8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,6 +29,7 @@ find_package(Qt5Xml)
 find_package(Qt5Sql)
 find_package(Qt5Network)
 find_package(Qt5LinguistTools)
+find_package(Qt5PrintSupport REQUIRED)
 IF(WIN32)
 	find_package(Qt5WinExtras)
 ENDIF()
diff --git a/src/HelpBrowser/CMakeLists.txt b/src/HelpBrowser/CMakeLists.txt
index 04319a8..5537dae 100644
--- a/src/HelpBrowser/CMakeLists.txt
+++ b/src/HelpBrowser/CMakeLists.txt
@@ -29,7 +29,7 @@ QT5_WRAP_UI(FILES_UI_H ${FILES_UI})

 ADD_LIBRARY(helpbrowser ${FILES_H} ${FILES_CPP} ${FILES_MOC} ${FILES_UI_H} ${FILES_HXX})
-qt5_use_modules(helpbrowser Core Concurrent Gui Widgets Xml WebKit WebKitWidgets)
+qt5_use_modules(helpbrowser Core Concurrent Gui Widgets Xml WebKit WebKitWidgets PrintSupport)

 SET(FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${FILES_CPP} ${FILES_H} ${FILES_UI} ${FILES_HXX} PARENT_SCOPE)
 SET(LUMINANCE_MODULES_GUI ${LUMINANCE_MODULES_GUI} helpbrowser PARENT_SCOPE)


code:
Fix static linking of 'lvm.static', which indirectly depend on libpthread
and libm via libdevmapper.a.

--- LVM2.2.02.166/tools/Makefile.in	2016-11-22 21:31:15.521045149 +0100
+++ LVM2.2.02.166/tools/Makefile.in	2016-11-22 21:31:24.085082767 +0100
@@ -148,7 +148,7 @@ endif

 lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
-	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(STATIC_LIBS) $(LIBS)
+	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(STATIC_LIBS) $(LIBS) $(PTHREAD_LIBS) $(M_LIBS)

 liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
 	cat $(top_builddir)/lib/liblvm-internal.a > $@
--- a/make.tmpl.in     2018-07-31 22:00:39.969983104 +0200
+++ b/make.tmpl.in     2018-07-31 22:00:58.467613682 +0200
@@ -53,7 +53,7 @@

 LIBS = @LIBS@
 # Extra libraries always linked with static binaries
-STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
+STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS) $(M_LIBS)
 DEFS += @DEFS@
 # FIXME set this only where it's needed, not globally?
 CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@