From: Bruno Haible Date: Tue, 30 Dec 2003 11:33:18 +0000 (+0000) Subject: Verify that the pushback buffer's size is sufficient. X-Git-Tag: v0.14~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0d82abfea6b3c6fdf29ec4cc460f8305cde95b4;p=thirdparty%2Fgettext.git Verify that the pushback buffer's size is sufficient. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index d259c5718..894166a87 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,35 @@ +2003-12-14 Bruno Haible + + * x-c.c (SIZEOF): New macro. + (phase1_ungetc): Verify that the pushback buffer's size is sufficient. + (phase2_ungetc): Likewise. + (phase3_ungetc): Likewise. + (phase5_unget): Likewise. + (phase6_unget): Likewise. + * x-java.c (SIZEOF): New macro. + (phase1_ungetc): Verify that the pushback buffer's size is sufficient. + (phase2_ungetc): Likewise. + (phase3_ungetc): Likewise. + (phase5_unget): Likewise. + (phase6_unget): Likewise. + * x-php.c (SIZEOF): New macro. + (phase1_ungetc): Verify that the pushback buffer's size is sufficient. + (phase2_ungetc): Likewise. + (phase3_ungetc): Likewise. + * x-python.c (SIZEOF): New macro. + (phase1_ungetc): Verify that the pushback buffer's size is sufficient. + (phase5_unget): Likewise. + * x-sh.c (SIZEOF): New macro. + (phase1_ungetc): Verify that the pushback buffer's size is sufficient. + (phase2_ungetc): Likewise. + * x-smalltalk.c (SIZEOF): New macro. + (phase2_unget): Verify that the pushback buffer's size is sufficient. + * x-tcl.c (SIZEOF): New macro. + (phase1_ungetc): Verify that the pushback buffer's size is sufficient. + (phase2_ungetc): Likewise. + * x-ycp.c (SIZEOF): New macro. + (phase2_unget): Verify that the pushback buffer's size is sufficient. + 2003-12-14 Bruno Haible * x-c.c (phase1_pushback): Reduce size to 2. diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index 22b9e40ee..52a79ceeb 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -39,6 +39,8 @@ #define _(s) gettext(s) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + /* The ANSI C standard defines several phases of translation: @@ -436,6 +438,8 @@ phase1_ungetc (int c) /* FALLTHROUGH */ default: + if (phase1_pushback_length == SIZEOF (phase1_pushback)) + abort (); phase1_pushback[phase1_pushback_length++] = c; break; } @@ -502,7 +506,11 @@ static void phase2_ungetc (int c) { if (c != EOF) - phase2_pushback[phase2_pushback_length++] = c; + { + if (phase2_pushback_length == SIZEOF (phase2_pushback)) + abort (); + phase2_pushback[phase2_pushback_length++] = c; + } } @@ -539,7 +547,11 @@ static void phase3_ungetc (int c) { if (c != EOF) - phase3_pushback[phase3_pushback_length++] = c; + { + if (phase3_pushback_length == SIZEOF (phase3_pushback)) + abort (); + phase3_pushback[phase3_pushback_length++] = c; + } } @@ -1167,7 +1179,11 @@ static void phase5_unget (token_ty *tp) { if (tp->type != token_type_eof) - phase5_pushback[phase5_pushback_length++] = *tp; + { + if (phase5_pushback_length == SIZEOF (phase5_pushback)) + abort (); + phase5_pushback[phase5_pushback_length++] = *tp; + } } @@ -1306,7 +1322,11 @@ static void phase6_unget (token_ty *tp) { if (tp->type != token_type_eof) - phase6_pushback[phase6_pushback_length++] = *tp; + { + if (phase6_pushback_length == SIZEOF (phase6_pushback)) + abort (); + phase6_pushback[phase6_pushback_length++] = *tp; + } } diff --git a/gettext-tools/src/x-java.c b/gettext-tools/src/x-java.c index b18f19677..8bb0545e9 100644 --- a/gettext-tools/src/x-java.c +++ b/gettext-tools/src/x-java.c @@ -40,6 +40,8 @@ #define _(s) gettext(s) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + /* The Java syntax is defined in the Java Language Specification, Second Edition, @@ -190,10 +192,18 @@ phase1_ungetc (int c) && phase1_pushback[phase1_pushback_length - 1] >= MULTIPLE_U (0)) phase1_pushback[phase1_pushback_length - 1]++; else - phase1_pushback[phase1_pushback_length++] = MULTIPLE_U (1); + { + if (phase1_pushback_length == SIZEOF (phase1_pushback)) + abort (); + phase1_pushback[phase1_pushback_length++] = MULTIPLE_U (1); + } } else - phase1_pushback[phase1_pushback_length++] = c; + { + if (phase1_pushback_length == SIZEOF (phase1_pushback)) + abort (); + phase1_pushback[phase1_pushback_length++] = c; + } } } @@ -290,7 +300,11 @@ static void phase2_ungetc (int c) { if (c != P2_EOF) - phase2_pushback[phase2_pushback_length++] = c; + { + if (phase2_pushback_length == SIZEOF (phase2_pushback)) + abort (); + phase2_pushback[phase2_pushback_length++] = c; + } } @@ -356,6 +370,8 @@ phase3_ungetc (int c) { if (c == '\n') --line_number; + if (phase3_pushback_length == SIZEOF (phase3_pushback)) + abort (); phase3_pushback[phase3_pushback_length++] = c; } } @@ -1126,7 +1142,11 @@ static void phase5_unget (token_ty *tp) { if (tp->type != token_type_eof) - phase5_pushback[phase5_pushback_length++] = *tp; + { + if (phase5_pushback_length == SIZEOF (phase5_pushback)) + abort (); + phase5_pushback[phase5_pushback_length++] = *tp; + } } @@ -1203,7 +1223,11 @@ static void phase6_unget (token_ty *tp) { if (tp->type != token_type_eof) - phase6_pushback[phase6_pushback_length++] = *tp; + { + if (phase6_pushback_length == SIZEOF (phase6_pushback)) + abort (); + phase6_pushback[phase6_pushback_length++] = *tp; + } } diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c index db71b3982..80175e7ad 100644 --- a/gettext-tools/src/x-php.c +++ b/gettext-tools/src/x-php.c @@ -36,6 +36,8 @@ #define _(s) gettext(s) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + /* The PHP syntax is defined in phpdoc/manual/langref.html. See also php-4.1.0/Zend/zend_language_scanner.l. */ @@ -178,6 +180,8 @@ phase1_ungetc (int c) if (c == '\n') --line_number; + if (phase1_pushback_length == SIZEOF (phase1_pushback)) + abort (); phase1_pushback[phase1_pushback_length++] = c; } } @@ -515,7 +519,11 @@ static void phase2_ungetc (int c) { if (c != EOF) - phase2_pushback[phase2_pushback_length++] = c; + { + if (phase2_pushback_length == SIZEOF (phase2_pushback)) + abort (); + phase2_pushback[phase2_pushback_length++] = c; + } } #endif @@ -711,7 +719,11 @@ static void phase3_ungetc (int c) { if (c != EOF) - phase3_pushback[phase3_pushback_length++] = c; + { + if (phase3_pushback_length == SIZEOF (phase3_pushback)) + abort (); + phase3_pushback[phase3_pushback_length++] = c; + } } #endif diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index fb53dc350..3e2ced7a4 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -42,8 +42,11 @@ #include "gettext.h" #define _(s) gettext(s) + #define max(a,b) ((a) > (b) ? (a) : (b)) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + /* The Python syntax is defined in the Python Reference Manual /usr/share/doc/packages/python/html/ref/index.html. @@ -185,6 +188,8 @@ phase1_ungetc (int c) if (c == '\n') --line_number; + if (phase1_pushback_length == SIZEOF (phase1_pushback)) + abort (); phase1_pushback[phase1_pushback_length++] = c; } } @@ -951,7 +956,11 @@ static void phase5_unget (token_ty *tp) { if (tp->type != token_type_eof) - phase5_pushback[phase5_pushback_length++] = *tp; + { + if (phase5_pushback_length == SIZEOF (phase5_pushback)) + abort (); + phase5_pushback[phase5_pushback_length++] = *tp; + } } diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 5feda599c..66faadd78 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -38,6 +38,9 @@ #define _(s) gettext(s) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + + /* The sh syntax is defined in POSIX:2001, see http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html Summary of sh syntax: @@ -218,6 +221,8 @@ phase1_ungetc (int c) /* FALLTHROUGH */ default: + if (phase1_pushback_length == SIZEOF (phase1_pushback)) + abort (); phase1_pushback[phase1_pushback_length++] = c; break; } @@ -672,6 +677,8 @@ phase2_ungetc (int c) /* FALLTHROUGH */ default: + if (phase2_pushback_length == SIZEOF (phase2_pushback)) + abort (); phase2_pushback[phase2_pushback_length++] = c; break; } diff --git a/gettext-tools/src/x-smalltalk.c b/gettext-tools/src/x-smalltalk.c index 54768032f..f081f86b4 100644 --- a/gettext-tools/src/x-smalltalk.c +++ b/gettext-tools/src/x-smalltalk.c @@ -35,6 +35,9 @@ #define _(s) gettext(s) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + + /* The relevant parts of the Smalltalk syntax are: stringliteral ::= string | stringconst | symconst @@ -439,7 +442,11 @@ static void phase2_unget (token_ty *tp) { if (tp->type != token_type_eof) - phase2_pushback[phase2_pushback_length++] = *tp; + { + if (phase2_pushback_length == SIZEOF (phase2_pushback)) + abort (); + phase2_pushback[phase2_pushback_length++] = *tp; + } } diff --git a/gettext-tools/src/x-tcl.c b/gettext-tools/src/x-tcl.c index 1b4d64a87..75871b406 100644 --- a/gettext-tools/src/x-tcl.c +++ b/gettext-tools/src/x-tcl.c @@ -43,6 +43,8 @@ #define _(s) gettext(s) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + /* The Tcl syntax is defined in the Tcl.n manual page. Summary of Tcl syntax: @@ -223,6 +225,8 @@ phase1_ungetc (int c) /* FALLTHROUGH */ default: + if (phase1_pushback_length == SIZEOF (phase1_pushback)) + abort (); phase1_pushback[phase1_pushback_length++] = c; break; } @@ -307,6 +311,8 @@ phase2_ungetc (int c) ++brace_depth; break; } + if (phase2_pushback_length == SIZEOF (phase2_pushback)) + abort (); phase2_pushback[phase2_pushback_length++] = c; } } diff --git a/gettext-tools/src/x-ycp.c b/gettext-tools/src/x-ycp.c index 8a8beae37..6ab49a6d9 100644 --- a/gettext-tools/src/x-ycp.c +++ b/gettext-tools/src/x-ycp.c @@ -38,6 +38,8 @@ #define _(s) gettext(s) +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + /* The YCP syntax is defined in libycp/doc/syntax.html. See also libycp/src/scanner.ll. */ @@ -296,7 +298,11 @@ static void phase2_ungetc (int c) { if (c != EOF) - phase2_pushback[phase2_pushback_length++] = c; + { + if (phase2_pushback_length == SIZEOF (phase2_pushback)) + abort (); + phase2_pushback[phase2_pushback_length++] = c; + } }