aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2009-11-04 16:38:31 -0500
committermaximilian attems <max@stro.at>2010-03-22 00:29:17 +0100
commit74fc1cac1cf99d538b95ea285afd05af6c3fb5e2 (patch)
treed0f3387843c68cb30f0b24c44199a77c9cfdc2fe
parent66c4c006f26329f41f0f418672351eb8c3dc2154 (diff)
downloadklibc-74fc1cac1cf99d538b95ea285afd05af6c3fb5e2.tar.gz
[klibc] [PARSER] Fix syntax array size
On Mon, Sep 28, 2009 at 11:00:05AM +0200, Jim Meyering wrote: > A DEL (0177, dec 127) byte in a here-document would cause dash to > access uninitialized memory at the end of one of the syntax.c tables, > since those tables are sized to accommodate a maximum index of > BASESYNTAX + 126. Make the generated tables one byte larger. > printf ':<<\\E\n\200y\nE'|./dash > * src/mksyntax.c (filltable): Use 258, not 257 as the size, > so that BASESYNTAX(=130) + 127 is a valid index. > (print): Likewise. > Don't emit explicit array dimension in declaration. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/dash/mksyntax.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr/dash/mksyntax.c b/usr/dash/mksyntax.c
index 7a8a9ae075e9f..a23c18caebb1b 100644
--- a/usr/dash/mksyntax.c
+++ b/usr/dash/mksyntax.c
@@ -223,7 +223,7 @@ filltable(char *dftval)
{
int i;
- for (i = 0 ; i < 257; i++)
+ for (i = 0 ; i < 258; i++)
syntax[i] = dftval;
}
@@ -269,9 +269,9 @@ print(char *name)
int col;
fprintf(hfile, "extern const char %s[];\n", name);
- fprintf(cfile, "const char %s[%d] = {\n", name, 257);
+ fprintf(cfile, "const char %s[] = {\n", name);
col = 0;
- for (i = 0 ; i < 257; i++) {
+ for (i = 0 ; i < 258; i++) {
if (i == 0) {
fputs(" ", cfile);
} else if ((i & 03) == 0) {