hunspell: Assert if overflow and increase limits

This commit is contained in:
Ray Donnelly
2014-10-10 21:11:10 +01:00
parent 4bef6bb6f1
commit 87bb6dbef2
3 changed files with 56 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>
_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
}

View File

@@ -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);

View File

@@ -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