diff --git a/SOURCES/0001-Resolves-rhbz-1261421-crash-on-mashing-hangul-korean.patch b/SOURCES/0001-Resolves-rhbz-1261421-crash-on-mashing-hangul-korean.patch new file mode 100644 index 0000000..38b4e5a --- /dev/null +++ b/SOURCES/0001-Resolves-rhbz-1261421-crash-on-mashing-hangul-korean.patch @@ -0,0 +1,141 @@ +From 97e079a23d459aeb6e64435350d7710c90dbca85 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> +Date: Fri, 11 Sep 2015 13:28:52 +0100 +Subject: [PATCH] Resolves: rhbz#1261421 crash on mashing hangul korean + keyboard + +--- + src/hunspell/hunspell.cxx | 69 +++++++++++++++++++++++++++++++++++------------ + src/hunspell/hunspell.hxx | 4 ++- + src/hunspell/replist.cxx | 18 ++++++++++--- + src/hunspell/replist.hxx | 2 ++ + src/tools/hunspell.cxx | 2 +- + 6 files changed, 78 insertions(+), 24 deletions(-) + +diff --git a/src/hunspell/hunspell.cxx b/src/hunspell/hunspell.cxx +index 7fae54b..d8ef357 100644 +--- a/src/hunspell/hunspell.cxx ++++ b/src/hunspell/hunspell.cxx +@@ -12,6 +12,7 @@ + #endif + #include "csutil.hxx" + ++#include <limits> + #include <string> + + Hunspell::Hunspell(const char * affpath, const char * dpath, const char * key) +@@ -345,8 +346,13 @@ + + // input conversion + RepList * rl = (pAMgr) ? pAMgr->get_iconvtable() : NULL; +- if (rl && rl->conv(word, wspace)) wl = cleanword2(cw, wspace, unicw, &nc, &captype, &abbv); +- else wl = cleanword2(cw, word, unicw, &nc, &captype, &abbv); ++ int convstatus = rl ? rl->conv(word, wspace, MAXWORDUTF8LEN) : 0; ++ if (convstatus < 0) ++ return 0; ++ else if (convstatus > 0) ++ wl = cleanword2(cw, wspace, unicw, &nc, &captype, &abbv); ++ else ++ wl = cleanword2(cw, word, unicw, &nc, &captype, &abbv); + + int info2 = 0; + if (wl == 0 || maxdic == 0) return 1; +@@ -699,8 +705,13 @@ + + // input conversion + RepList * rl = (pAMgr) ? pAMgr->get_iconvtable() : NULL; +- if (rl && rl->conv(word, wspace)) wl = cleanword2(cw, wspace, unicw, &nc, &captype, &abbv); +- else wl = cleanword2(cw, word, unicw, &nc, &captype, &abbv); ++ int convstatus = rl ? rl->conv(word, wspace, MAXWORDUTF8LEN) : 0; ++ if (convstatus < 0) ++ return 0; ++ else if (convstatus > 0) ++ wl = cleanword2(cw, wspace, unicw, &nc, &captype, &abbv); ++ else ++ wl = cleanword2(cw, word, unicw, &nc, &captype, &abbv); + + if (wl == 0) return 0; + int ns = 0; +@@ -1008,7 +1019,7 @@ + // output conversion + rl = (pAMgr) ? pAMgr->get_oconvtable() : NULL; + for (int j = 0; rl && j < ns; j++) { +- if (rl->conv((*slst)[j], wspace)) { ++ if (rl->conv((*slst)[j], wspace, MAXWORDUTF8LEN) > 0) { + free((*slst)[j]); + (*slst)[j] = mystrdup(wspace); + } +@@ -1383,8 +1394,13 @@ + + // input conversion + RepList * rl = (pAMgr) ? pAMgr->get_iconvtable() : NULL; +- if (rl && rl->conv(word, wspace)) wl = cleanword2(cw, wspace, unicw, &nc, &captype, &abbv); +- else wl = cleanword2(cw, word, unicw, &nc, &captype, &abbv); ++ int convstatus = rl ? rl->conv(word, wspace, MAXWORDUTF8LEN) : 0; ++ if (convstatus < 0) ++ return 0; ++ else if (convstatus > 0) ++ wl = cleanword2(cw, wspace, unicw, &nc, &captype, &abbv); ++ else ++ wl = cleanword2(cw, word, unicw, &nc, &captype, &abbv); + + if (wl == 0) { + if (abbv) { +diff --git a/src/hunspell/replist.cxx b/src/hunspell/replist.cxx +index b9b1255..bac3e06 100644 +--- a/src/hunspell/replist.cxx ++++ b/src/hunspell/replist.cxx +@@ -74,6 +74,7 @@ + #include <stdlib.h> + #include <string.h> + #include <stdio.h> ++#include <limits> + + #include "replist.hxx" + #include "csutil.hxx" +@@ -139,19 +140,30 @@ int RepList::add(char * pat1, char * pat2) { + return 0; + } + +-int RepList::conv(const char * word, char * dest) { ++int RepList::conv(const char * word, char * dest, size_t destsize) { + int stl = 0; + int change = 0; + for (size_t i = 0; i < strlen(word); i++) { + int n = near(word + i); + int l = match(word + i, n); + if (l) { ++ size_t replen = strlen(dat[n]->pattern2); ++ if (stl+replen >= destsize) ++ return -1; + strcpy(dest + stl, dat[n]->pattern2); +- stl += strlen(dat[n]->pattern2); ++ stl += replen; + i += l - 1; + change = 1; +- } else dest[stl++] = word[i]; ++ } else { ++ if (stl+1 >= destsize) ++ return -1; ++ dest[stl++] = word[i]; ++ } + } + dest[stl] = '\0'; + return change; + } ++ ++int RepList::conv(const char * word, char * dest) { ++ return conv(word, dest, std::numeric_limits<std::size_t>::max()); ++} +diff --git a/src/hunspell/replist.hxx b/src/hunspell/replist.hxx +index 1e3d6e4..e418298 100644 +--- a/src/hunspell/replist.hxx ++++ b/src/hunspell/replist.hxx +@@ -99,5 +99,7 @@ public: + int near(const char * word); + int match(const char * word, int n); + int conv(const char * word, char * dest); ++ // ^^-deprecated, use this-vv" ++ int conv(const char * word, char * dest, size_t destsize); + }; + #endif diff --git a/SOURCES/hunspell.rhbz915448.patch b/SOURCES/hunspell.rhbz915448.patch new file mode 100644 index 0000000..7b9c9fc --- /dev/null +++ b/SOURCES/hunspell.rhbz915448.patch @@ -0,0 +1,55 @@ +--- src/tools/hunspell.cxx~0 2011-01-21 19:01:29.000000000 +0200 ++++ src/tools/hunspell.cxx 2013-02-07 10:11:54.443610900 +0200 +@@ -710,13 +748,22 @@ if (pos >= 0) { + fflush(stdout); + } else { + char ** wlst = NULL; +- int ns = pMS[d]->suggest(&wlst, token); ++ int byte_offset = parser->get_tokenpos() + pos; ++ int char_offset = 0; ++ if (strcmp(io_enc, "UTF-8") == 0) { ++ for (int i = 0; i < byte_offset; i++) { ++ if ((buf[i] & 0xc0) != 0x80) ++ char_offset++; ++ } ++ } else { ++ char_offset = byte_offset; ++ } ++ int ns = pMS[d]->suggest(&wlst, chenc(token, io_enc, dic_enc[d])); + if (ns == 0) { +- fprintf(stdout,"# %s %d", token, +- parser->get_tokenpos() + pos); ++ fprintf(stdout,"# %s %d", token, char_offset); + } else { + fprintf(stdout,"& %s %d %d: ", token, ns, +- parser->get_tokenpos() + pos); ++ char_offset); + fprintf(stdout,"%s", chenc(wlst[0], dic_enc[d], io_enc)); + } + for (int j = 1; j < ns; j++) { +@@ -745,13 +792,23 @@ if (pos >= 0) { + if (root) free(root); + } else { + char ** wlst = NULL; ++ int byte_offset = parser->get_tokenpos() + pos; ++ int char_offset = 0; ++ if (strcmp(io_enc, "UTF-8") == 0) { ++ for (int i = 0; i < byte_offset; i++) { ++ if ((buf[i] & 0xc0) != 0x80) ++ char_offset++; ++ } ++ } else { ++ char_offset = byte_offset; ++ } + int ns = pMS[d]->suggest(&wlst, chenc(token, io_enc, dic_enc[d])); + if (ns == 0) { + fprintf(stdout,"# %s %d", chenc(token, io_enc, ui_enc), +- parser->get_tokenpos() + pos); ++ char_offset); + } else { + fprintf(stdout,"& %s %d %d: ", chenc(token, io_enc, ui_enc), ns, +- parser->get_tokenpos() + pos); ++ char_offset); + fprintf(stdout,"%s", chenc(wlst[0], dic_enc[d], ui_enc)); + } + for (int j = 1; j < ns; j++) { diff --git a/SPECS/hunspell.spec b/SPECS/hunspell.spec index 0a022c2..96d0a6b 100644 --- a/SPECS/hunspell.spec +++ b/SPECS/hunspell.spec @@ -3,7 +3,7 @@ Name: hunspell Summary: A spell checker and morphological analyzer library Version: 1.3.2 -Release: 13%{?dist} +Release: 15%{?dist} Source: http://downloads.sourceforge.net/%{name}/hunspell-%{version}.tar.gz Group: System Environment/Libraries URL: http://hunspell.sourceforge.net/ @@ -20,6 +20,8 @@ Requires: hunspell-en-US Patch0: hunspell.rhbz759647.patch Patch1: hunspell.rhbz918938.patch Patch2: hunspell-aarch64.patch +Patch3: 0001-Resolves-rhbz-1261421-crash-on-mashing-hangul-korean.patch +Patch4: hunspell.rhbz915448.patch %description Hunspell is a spell checker and morphological analyzer library and program @@ -40,6 +42,8 @@ Includes and definitions for developing with hunspell %patch0 -p0 -b .rhbz759647 %patch1 -p0 -b .rhbz918938 %patch2 -p1 -b .aarch64 +%patch3 -p1 -b .rhbz-1261421-crash-on-mashing-hangul-korean +%patch4 -p0 -b .rhbz915448 %build configureflags="--disable-rpath --disable-static --with-ui --with-readline" @@ -129,6 +133,12 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man3/hunspell.3.gz %changelog +* Wed Aug 10 2016 Caolán McNamara <caolanm@redhat.com> - 1.3.2-15 +- Resolves: rhbz#1262755 bad UTF-8 char count in pipe mode + +* Tue Mar 01 2016 Caolán McNamara <caolanm@redhat.com> - 1.3.2-14 +- Resolves: rhbz#1261421 crash on mashing hangul keyboard + * Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 1.3.2-13 - Mass rebuild 2014-01-24