hnj_hyphen_hyphword: add test to detect overflows
This commit is contained in:
parent
4e09ea69d6
commit
568e5f92b3
|
@ -67,7 +67,7 @@ main(int argc, char** argv)
|
|||
char *hyphens;
|
||||
char *lcword;
|
||||
char *hyphword;
|
||||
char hword[BUFSIZE * 2];
|
||||
char *hword;
|
||||
int arg = 1;
|
||||
int optd = 1;
|
||||
int optn = 0;
|
||||
|
@ -151,12 +151,16 @@ main(int argc, char** argv)
|
|||
rep = NULL;
|
||||
pos = NULL;
|
||||
cut = NULL;
|
||||
|
||||
/* set minimum required output buffer size (2 * word_size) */
|
||||
hword = (char *) malloc((n-1)*2);
|
||||
hword[0] = '\0';
|
||||
|
||||
if ((!optd && hnj_hyphen_hyphenate(dict, lcword, n-1, hyphens)) ||
|
||||
(optd && hnj_hyphen_hyphenate2(dict, lcword, n-1, hyphens, hword, &rep, &pos, &cut))) {
|
||||
free(hyphens);
|
||||
free(lcword);
|
||||
free(hword);
|
||||
fprintf(stderr, "hyphenation error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -202,6 +206,7 @@ main(int argc, char** argv)
|
|||
}
|
||||
free(hyphens);
|
||||
free(lcword);
|
||||
free(hword);
|
||||
}
|
||||
|
||||
fclose(wtclst);
|
||||
|
|
|
@ -10,6 +10,7 @@ alt3.test \
|
|||
alt4.test \
|
||||
alt5.test \
|
||||
alt6.test \
|
||||
alt7.test \
|
||||
compound.test \
|
||||
compound2.test \
|
||||
compound3.test \
|
||||
|
@ -46,6 +47,9 @@ alt5.word \
|
|||
alt6.hyph \
|
||||
alt6.pat \
|
||||
alt6.word \
|
||||
alt7.hyph \
|
||||
alt7.pat \
|
||||
alt7.word \
|
||||
alt.hyph \
|
||||
alt.pat \
|
||||
alt.word \
|
||||
|
@ -100,6 +104,7 @@ alt3.test \
|
|||
alt4.test \
|
||||
alt5.test \
|
||||
alt6.test \
|
||||
alt7.test \
|
||||
alt.test \
|
||||
basealt2.test \
|
||||
basealt.test \
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
b=bbbbbbbbbbbbbbbbbbbbbba=a=a=a=a=a=a=a=a=a=a=a=a=a=a=a
|
||||
b=bbbbbbbbbbbbbbbbbbbbbba=b=bbbbbbbbbbbbbbbbbbbbbba=b=b
|
|
@ -0,0 +1,7 @@
|
|||
ISO8859-1
|
||||
LEFTHYPHENMIN 1
|
||||
RIGHTHYPHENMIN 1
|
||||
% Check for buffer overflows
|
||||
.a1b.
|
||||
a9a
|
||||
ab3a/b=bbbbbbbbbbbbbbbbbbbbbb,1,2
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
DIR="`dirname $0`"
|
||||
NAME="`basename $0 .test`"
|
||||
$DIR/test.sh $NAME.pat $NAME.word $NAME.hyph
|
|
@ -0,0 +1,2 @@
|
|||
abaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
abaabaababababababababababab
|
Loading…
Reference in New Issue