diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-09-07 23:17:14 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-09-07 23:17:14 +0000 |
commit | 09e99a10827e4300daf733a57748405e22e51181 (patch) | |
tree | 79fe70365b8a4c6ed2151e603825668e045a0919 /src/interfaces/ecpg | |
parent | b6385efb7907e1aefe65a699bb1fcc115d98ee23 (diff) |
Change addlit() to not assume its input is null-terminated, so that we
don't have more bugs like the quote-quote-quote-quote one. Propagate
fix into ecpg lexer, too.
Diffstat (limited to 'src/interfaces/ecpg')
-rw-r--r-- | src/interfaces/ecpg/preproc/pgc.l | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 5929f1f1713..d6d99adcee3 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.79 2001/06/13 12:38:58 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.80 2001/09/07 23:17:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -35,6 +35,8 @@ extern YYSTYPE yylval; +static int xcdepth = 0; /* depth of nesting in slash-star comments */ + /* * literalbuf is used to accumulate literal values when multiple rules * are needed to parse a single literal. Call startlit to reset buffer @@ -45,8 +47,6 @@ static char *literalbuf = NULL; /* expandable buffer */ static int literallen; /* actual current length */ static int literalalloc; /* current allocated buffer size */ -static int xcdepth = 0; - #define startlit() (literalbuf[0] = '\0', literallen = 0) static void addlit(char *ytext, int yleng); @@ -923,9 +923,10 @@ addlit(char *ytext, int yleng) } while ((literallen+yleng) >= literalalloc); literalbuf = (char *) realloc(literalbuf, literalalloc); } - /* append data --- note we assume ytext is null-terminated */ - memcpy(literalbuf+literallen, ytext, yleng+1); + /* append new data, add trailing null */ + memcpy(literalbuf+literallen, ytext, yleng); literallen += yleng; + literalbuf[literallen] = '\0'; } int yywrap(void) |