diff options
author | Michael Stahl <mst@openoffice.org> | 2012-07-27 17:31:15 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-27 17:50:23 +0200 |
commit | aab05a9444088c1ade1688ab8ab12f588962e8cd (patch) | |
tree | d8d489693525a21aaac0236ff010afaad1d7e1ea /hunspell | |
parent | 6a94d7b5c924e3a8ef3ff0f68f54061c035a3cb0 (diff) |
hunspell: fix warnings
Diffstat (limited to 'hunspell')
-rw-r--r-- | hunspell/hunspell-1.3.2-overflow.patch | 91 | ||||
-rw-r--r-- | hunspell/makefile.mk | 1 |
2 files changed, 92 insertions, 0 deletions
diff --git a/hunspell/hunspell-1.3.2-overflow.patch b/hunspell/hunspell-1.3.2-overflow.patch new file mode 100644 index 000000000000..46d4c6787be2 --- /dev/null +++ b/hunspell/hunspell-1.3.2-overflow.patch @@ -0,0 +1,91 @@ +--- misc/hunspell-1.3.2/src/hunspell/affixmgr.cxx 2010-02-27 12:59:53.000000000 +0100 ++++ misc/build/hunspell-1.3.2/src/hunspell/affixmgr.cxx 2011-05-18 16:29:45.919141893 +0200 +@@ -6,6 +6,8 @@ + #include <stdio.h> + #include <ctype.h> + ++#include <limits> ++ + #include "affixmgr.hxx" + #include "affentry.hxx" + #include "langnum.hxx" +@@ -4000,7 +4002,10 @@ + case 3: { + np++; + numents = atoi(piece); +- if (numents == 0) { ++ if ((numents <= 0) || ++ ((::std::numeric_limits<size_t>::max() ++ / sizeof(struct affentry)) < numents)) ++ { + char * err = pHMgr->encode_flag(aflag); + if (err) { + HUNSPELL_WARNING(stderr, "error: line %d: bad entry number\n", +--- misc/hunspell-1.3.2/src/tools/munch.c 2010-02-27 21:49:49.000000000 +0100 ++++ misc/build/hunspell-1.3.2/src/tools/munch.c 2011-05-18 15:53:53.427072106 +0200 +@@ -4,6 +4,7 @@ + #include <string.h> + #include <unistd.h> + #include <stdlib.h> ++#include <stdint.h> + #include <stdio.h> + #include <sys/types.h> + #include <sys/stat.h> +@@ -233,10 +233,19 @@ + case 1: { achar = *piece; break; } + case 2: { if (*piece == 'Y') ff = XPRODUCT; break; } + case 3: { numents = atoi(piece); +- ptr = malloc(numents * sizeof(struct affent)); +- ptr->achar = achar; +- ptr->xpflg = ff; +- fprintf(stderr,"parsing %c entries %d\n",achar,numents); ++ if ((numents < 0) || ++ ((SIZE_MAX/sizeof(struct affent)) < numents)) ++ { ++ fprintf(stderr, ++ "Error: too many entries: %d\n", numents); ++ numents = 0; ++ } else { ++ ptr = malloc(numents * sizeof(struct affent)); ++ ptr->achar = achar; ++ ptr->xpflg = ff; ++ fprintf(stderr,"parsing %c entries %d\n", ++ achar,numents); ++ } + break; + } + default: break; +--- misc/hunspell-1.3.2/src/tools/unmunch.c 2010-02-23 15:53:29.000000000 +0100 ++++ misc/build/hunspell-1.3.2/src/tools/unmunch.c 2011-05-18 20:53:43.843599726 +0200 +@@ -6,6 +6,7 @@ + #include <string.h> + #include <unistd.h> + #include <stdlib.h> ++#include <stdint.h> + #include <stdio.h> + #include <sys/types.h> + #include <sys/stat.h> +@@ -158,10 +159,19 @@ + case 1: { achar = *piece; break; } + case 2: { if (*piece == 'Y') ff = XPRODUCT; break; } + case 3: { numents = atoi(piece); +- ptr = malloc(numents * sizeof(struct affent)); +- ptr->achar = achar; +- ptr->xpflg = ff; +- fprintf(stderr,"parsing %c entries %d\n",achar,numents); ++ if ((numents < 0) || ++ ((SIZE_MAX/sizeof(struct affent)) < numents)) ++ { ++ fprintf(stderr, ++ "Error: too many entries: %d\n", numents); ++ numents = 0; ++ } else { ++ ptr = malloc(numents * sizeof(struct affent)); ++ ptr->achar = achar; ++ ptr->xpflg = ff; ++ fprintf(stderr,"parsing %c entries %d\n", ++ achar,numents); ++ } + break; + } + default: break; diff --git a/hunspell/makefile.mk b/hunspell/makefile.mk index c4377a631b56..65ca45b70be8 100644 --- a/hunspell/makefile.mk +++ b/hunspell/makefile.mk @@ -45,6 +45,7 @@ PATCH_FILES=\ hunspell-static.patch \ hunspell-wntconfig.patch \ hunspell-solaris.patch \ + hunspell-1.3.2-overflow.patch \ hunspell-android.patch .IF "$(GUI)"=="UNX" |