mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Simplify lexer's rules for string constants, eliminate potential buffer overrun.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.44 1998/10/08 18:29:51 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.45 1999/02/07 23:58:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -108,13 +108,14 @@ xhcat {quote}{space}*\n{space}*{quote}
|
||||
/* Extended quote
|
||||
* xqdouble implements SQL92 embedded quote
|
||||
* xqcat allows strings to cross input lines
|
||||
* Note: reduction of '' and \ sequences to output text is done in scanstr(),
|
||||
* not by rules here.
|
||||
*/
|
||||
quote '
|
||||
xqstart {quote}
|
||||
xqstop {quote}
|
||||
xqdouble {quote}{quote}
|
||||
xqinside [^\\']*
|
||||
xqembedded "\\'"
|
||||
xqliteral [\\](.|\n)
|
||||
xqcat {quote}{space}*\n{space}*{quote}
|
||||
|
||||
@@ -241,22 +242,9 @@ other .
|
||||
return SCONST;
|
||||
}
|
||||
<xq>{xqdouble} |
|
||||
<xq>{xqinside} {
|
||||
if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1))
|
||||
elog(ERROR,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
|
||||
memcpy(literal+llen, yytext, yyleng+1);
|
||||
llen += yyleng;
|
||||
}
|
||||
<xq>{xqembedded} {
|
||||
if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1))
|
||||
elog(ERROR,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
|
||||
memcpy(literal+llen, yytext, yyleng+1);
|
||||
*(literal+llen) = '\'';
|
||||
llen += yyleng;
|
||||
}
|
||||
|
||||
<xq>{xqinside} |
|
||||
<xq>{xqliteral} {
|
||||
if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1))
|
||||
if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1))
|
||||
elog(ERROR,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
|
||||
memcpy(literal+llen, yytext, yyleng+1);
|
||||
llen += yyleng;
|
||||
|
Reference in New Issue
Block a user