You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-text/aspell/files/aspell-0.50.5-charcount.patch

78 lines
2.2 KiB

diff -Nrup aspell-0.50.5.orig/prog/compress.c aspell-0.50.5/prog/compress.c
--- aspell-0.50.5.orig/prog/compress.c 2002-08-31 14:51:11.000000000 -0400
+++ aspell-0.50.5/prog/compress.c 2004-08-15 15:07:26.000000000 -0400
@@ -28,24 +28,27 @@
#endif
+#define BUFSIZE 256
+
void usage ()
{
fputs("Compresses or uncompresses sorted word lists.\n" , stderr);
fputs("For best result the locale should be set to C\n" , stderr);
fputs("before sorting by setting the environmental\n" , stderr);
fputs("variable LANG to \"C\" before sorting.\n" , stderr);
- fputs("Copyright 2001 by Kevin Atkinson.\n" , stderr);
+ fputs("Copyright 2001-2004 by Kevin Atkinson.\n" , stderr);
fputs("Usage: word-list-compress c[ompress]|d[ecompress]\n" , stderr);
}
-static int get_word(FILE * in, char * w)
+static int get_word(FILE * in, char * w, size_t bufsize)
{
int c;
while (c = getc(in), c != EOF && c <= 32);
if (c == EOF) return 0;
do {
*w++ = (char)(c);
- } while (c = getc(in), c != EOF && c > 32);
+ --bufsize;
+ } while (c = getc(in), c != EOF && c > 32 && bufsize > 1);
*w = '\0';
ungetc(c, in);
if (c == EOF) return 0;
@@ -61,15 +64,15 @@ int main (int argc, const char *argv[])
} else if (argv[1][0] == 'c') {
- char s1[256];
- char s2[256];
+ char s1[BUFSIZE];
+ char s2[BUFSIZE];
char * prev = s2;
char * cur = s1;
*prev = '\0';
SETBIN (stdout);
- while (get_word(stdin, cur)) {
+ while (get_word(stdin, cur, BUFSIZE)) {
int i = 0;
/* get the length of the prefix */
while (prev[i] != '\0' && cur[i] != '\0' && prev[i] == cur[i])
@@ -99,9 +102,10 @@ int main (int argc, const char *argv[])
while (i != -1 ) {
if (i == 0)
i = getc(stdin);
- --i;
- while ((c = getc(stdin)) > 32)
+ --i; if (i < 0) goto error;
+ while ((c = getc(stdin)) > 32 && i < BUFSIZE)
cur[i++] = (char)c;
+ if (i >= BUFSIZE) goto error;
cur[i] = '\0';
fputs(cur, stdout);
putc('\n', stdout);
@@ -109,6 +113,10 @@ int main (int argc, const char *argv[])
}
return 0;
+error:
+ fputs("ERROR: Corrupt Input.\n", stderr);
+ return 2;
+
} else {
usage();