Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit09e99a1

Browse files
committed
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. Propagatefix into ecpg lexer, too.
1 parentb6385ef commit09e99a1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

‎src/backend/parser/scan.l

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.89 2001/09/04 00:19:39 petere Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.90 2001/09/07 23:17:14 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -69,6 +69,8 @@ void unput(char);
6969

7070
extern YYSTYPE yylval;
7171

72+
staticintxcdepth =0;/* depth of nesting in slash-star comments*/
73+
7274
/*
7375
* literalbuf is used to accumulate literal values when multiple rules
7476
* are needed to parse a single literal. Call startlit to reset buffer
@@ -79,8 +81,6 @@ static char *literalbuf;/* expandable buffer */
7981
staticintliterallen;/* actual current length*/
8082
staticintliteralalloc;/* current allocated buffer size*/
8183

82-
staticintxcdepth =0;/* depth of nesting in slash-star comments*/
83-
8484
#definestartlit() (literalbuf[0] ='\0', literallen =0)
8585
staticvoidaddlit(char *ytext,int yleng);
8686

@@ -375,7 +375,7 @@ other.
375375
return IDENT;
376376
}
377377
<xd>{xddouble} {
378-
addlit(yytext+1, yyleng-1);
378+
addlit(yytext, yyleng-1);
379379
}
380380
<xd>{xdinside}{
381381
addlit(yytext, yyleng);
@@ -581,9 +581,10 @@ addlit(char *ytext, int yleng)
581581
}while ((literallen+yleng) >= literalalloc);
582582
literalbuf = (char *)repalloc(literalbuf, literalalloc);
583583
}
584-
/* append data --- note we assume ytext isnull-terminated */
585-
memcpy(literalbuf+literallen, ytext, yleng+1);
584+
/* appendnewdata, add trailingnull */
585+
memcpy(literalbuf+literallen, ytext, yleng);
586586
literallen += yleng;
587+
literalbuf[literallen] ='\0';
587588
}
588589

589590
#if !defined(FLEX_SCANNER)

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.79 2001/06/13 12:38:58 meskes Exp $
15+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.80 2001/09/07 23:17:14 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -35,6 +35,8 @@
3535

3636
extern YYSTYPE yylval;
3737

38+
staticintxcdepth =0;/* depth of nesting in slash-star comments*/
39+
3840
/*
3941
* literalbuf is used to accumulate literal values when multiple rules
4042
* are needed to parse a single literal. Call startlit to reset buffer
@@ -45,8 +47,6 @@ static char *literalbuf = NULL;/* expandable buffer */
4547
staticintliterallen;/* actual current length*/
4648
staticintliteralalloc;/* current allocated buffer size*/
4749

48-
staticint xcdepth =0;
49-
5050
#definestartlit() (literalbuf[0] ='\0', literallen =0)
5151
staticvoidaddlit(char *ytext,int yleng);
5252

@@ -923,9 +923,10 @@ addlit(char *ytext, int yleng)
923923
}while ((literallen+yleng) >= literalalloc);
924924
literalbuf = (char *)realloc(literalbuf, literalalloc);
925925
}
926-
/* append data --- note we assume ytext isnull-terminated */
927-
memcpy(literalbuf+literallen, ytext, yleng+1);
926+
/* appendnewdata, add trailingnull */
927+
memcpy(literalbuf+literallen, ytext, yleng);
928928
literallen += yleng;
929+
literalbuf[literallen] ='\0';
929930
}
930931

931932
intyywrap(void)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp