From 87bb6dbef2133128fa856bb30d572d46de82ec43 Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Fri, 10 Oct 2014 21:11:10 +0100 Subject: [PATCH] hunspell: Assert if overflow and increase limits --- mingw-w64-hunspell/PKGBUILD | 27 ++++++++++++------- ...-1.3.3-exit-on-MAX_PREFIXES_SUFFIXES.patch | 25 +++++++++++++++++ ....3-inc-MAX_PREFIXES_SUFFIXES-to-2048.patch | 14 ++++++++++ 3 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 mingw-w64-hunspell/hunspell-1.3.3-exit-on-MAX_PREFIXES_SUFFIXES.patch create mode 100644 mingw-w64-hunspell/hunspell-1.3.3-inc-MAX_PREFIXES_SUFFIXES-to-2048.patch diff --git a/mingw-w64-hunspell/PKGBUILD b/mingw-w64-hunspell/PKGBUILD index da64fcbb85..fc81cd463c 100644 --- a/mingw-w64-hunspell/PKGBUILD +++ b/mingw-w64-hunspell/PKGBUILD @@ -1,4 +1,5 @@ # Maintainer: Alexey Pavlov +# Contributor: Ray Donnelly _realname=hunspell pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" @@ -11,24 +12,30 @@ license=("BSD") makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config") depends=(${MINGW_PACKAGE_PREFIX}-gcc-libs ${MINGW_PACKAGE_PREFIX}-gettext) -options=('!libtool' 'strip') +options=('!libtool' 'strip' '!debug') source=("http://download.sourceforge.net/${_realname}/${_realname}-$pkgver.tar.gz" - "hunspell-1.3.2-canonicalhost.patch") + "hunspell-1.3.2-canonicalhost.patch" + "hunspell-1.3.3-exit-on-MAX_PREFIXES_SUFFIXES.patch" + "hunspell-1.3.3-inc-MAX_PREFIXES_SUFFIXES-to-2048.patch") md5sums=('4967da60b23413604c9e563beacc63b4' - 'f8a5c0f3692a390d98daf0406da59cdf') + 'f8a5c0f3692a390d98daf0406da59cdf' + 'c6cd1edc5bbfb803a6dc2ef602e048a3' + 'ebf66e5be21328c22df969245a9e75a8') prepare() { cd "$srcdir/${_realname}-$pkgver" - patch -Np1 -i "$srcdir/hunspell-1.3.2-canonicalhost.patch" - + patch -Np1 -i "$srcdir"/hunspell-1.3.2-canonicalhost.patch + patch -Np1 -i "$srcdir"/hunspell-1.3.3-exit-on-MAX_PREFIXES_SUFFIXES.patch + patch -Np1 -i "$srcdir"/hunspell-1.3.3-inc-MAX_PREFIXES_SUFFIXES-to-2048.patch + autoreconf -fi } build() { - mkdir -p "${srcdir}/build-${MINGW_CHOST}" - cd "${srcdir}/build-${MINGW_CHOST}" - + mkdir -p "${srcdir}/build-${CARCH}" + cd "${srcdir}/build-${CARCH}" + ${srcdir}/${_realname}-${pkgver}/configure \ --build=${MINGW_CHOST} \ --host=${MINGW_CHOST} \ @@ -38,12 +45,12 @@ build() { --enable-threads=posix \ --without-ui \ --without-readline - + make } package() { - cd "${srcdir}/build-${MINGW_CHOST}" + cd "${srcdir}/build-${CARCH}" make DESTDIR="${pkgdir}" install cp ${pkgdir}${MINGW_PREFIX}/lib/lib${_realname}-${pkgver%.*}.dll.a ${pkgdir}${MINGW_PREFIX}/lib/lib${_realname}.dll.a } diff --git a/mingw-w64-hunspell/hunspell-1.3.3-exit-on-MAX_PREFIXES_SUFFIXES.patch b/mingw-w64-hunspell/hunspell-1.3.3-exit-on-MAX_PREFIXES_SUFFIXES.patch new file mode 100644 index 0000000000..605bf63fa6 --- /dev/null +++ b/mingw-w64-hunspell/hunspell-1.3.3-exit-on-MAX_PREFIXES_SUFFIXES.patch @@ -0,0 +1,25 @@ +diff -urN hunspell-1.3.3.orig/src/tools/munch.c hunspell-1.3.3/src/tools/munch.c +--- hunspell-1.3.3.orig/src/tools/munch.c 2014-10-10 21:04:57.722628800 +0100 ++++ hunspell-1.3.3/src/tools/munch.c 2014-10-10 21:06:49.717034500 +0100 +@@ -294,11 +294,21 @@ + nptr++; + } + if (ft == 'P') { ++ if (numpfx == MAX_PREFIXES) { ++ fprintf(stderr,"MAX_PREFIXES (%d) reached.",MAX_PREFIXES); ++ fprintf(stderr,"please edit value in src/tools/munch.h and rebuild hunspell\n"); ++ exit(1); ++ } + ptable[numpfx].aep = ptr; + ptable[numpfx].num = numents; + fprintf(stderr,"ptable %d num is %d\n",numpfx,ptable[numpfx].num); + numpfx++; + } else { ++ if (numsfx == MAX_SUFFIXES) { ++ fprintf(stderr,"MAX_SUFFIXES (%d) reached.",MAX_SUFFIXES); ++ fprintf(stderr,"please edit value in src/tools/munch.h and rebuild hunspell\n"); ++ exit(1); ++ } + stable[numsfx].aep = ptr; + stable[numsfx].num = numents; + fprintf(stderr,"stable %d num is %d\n",numsfx,stable[numsfx].num); diff --git a/mingw-w64-hunspell/hunspell-1.3.3-inc-MAX_PREFIXES_SUFFIXES-to-2048.patch b/mingw-w64-hunspell/hunspell-1.3.3-inc-MAX_PREFIXES_SUFFIXES-to-2048.patch new file mode 100644 index 0000000000..fc553a262b --- /dev/null +++ b/mingw-w64-hunspell/hunspell-1.3.3-inc-MAX_PREFIXES_SUFFIXES-to-2048.patch @@ -0,0 +1,14 @@ +diff -urN hunspell-1.3.3.orig/src/tools/munch.h hunspell-1.3.3/src/tools/munch.h +--- hunspell-1.3.3.orig/src/tools/munch.h 2014-10-10 21:07:39.378875000 +0100 ++++ hunspell-1.3.3/src/tools/munch.h 2014-10-10 21:08:20.397221100 +0100 +@@ -2,8 +2,8 @@ + + #define MAX_LN_LEN 200 + #define MAX_WD_LEN 200 +-#define MAX_PREFIXES 256 +-#define MAX_SUFFIXES 256 ++#define MAX_PREFIXES 2048 ++#define MAX_SUFFIXES 2048 + #define MAX_ROOTS 20 + #define MAX_WORDS 5000 +