Commit f7c6a88c authored by Tom Lane's avatar Tom Lane

Simplify lexer's rules for string constants, eliminate potential buffer overrun.

parent 45ff93c4
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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} ...@@ -108,13 +108,14 @@ xhcat {quote}{space}*\n{space}*{quote}
/* Extended quote /* Extended quote
* xqdouble implements SQL92 embedded quote * xqdouble implements SQL92 embedded quote
* xqcat allows strings to cross input lines * xqcat allows strings to cross input lines
* Note: reduction of '' and \ sequences to output text is done in scanstr(),
* not by rules here.
*/ */
quote ' quote '
xqstart {quote} xqstart {quote}
xqstop {quote} xqstop {quote}
xqdouble {quote}{quote} xqdouble {quote}{quote}
xqinside [^\\']* xqinside [^\\']*
xqembedded "\\'"
xqliteral [\\](.|\n) xqliteral [\\](.|\n)
xqcat {quote}{space}*\n{space}*{quote} xqcat {quote}{space}*\n{space}*{quote}
...@@ -241,22 +242,9 @@ other . ...@@ -241,22 +242,9 @@ other .
return SCONST; return SCONST;
} }
<xq>{xqdouble} | <xq>{xqdouble} |
<xq>{xqinside} { <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>{xqliteral} { <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); elog(ERROR,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
memcpy(literal+llen, yytext, yyleng+1); memcpy(literal+llen, yytext, yyleng+1);
llen += yyleng; llen += yyleng;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment