Skip to content

Commit 44c2163

Browse files
committed
Fix length checking for Unicode identifiers containing escapes (U&"...").
We used the length of the input string, not the de-escaped string, as the trigger for NAMEDATALEN truncation. AFAICS this would only result in sometimes printing a phony truncation warning; but it's just luck that there was no worse problem, since we were violating the API spec for truncate_identifier(). Per bug #9204 from Joshua Yanovski. This has been wrong since the Unicode-identifier support was added, so back-patch to all supported branches.
1 parent 3f735ae commit 44c2163

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/backend/parser/scan.l

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,22 +737,25 @@ other .
737737
<xuiend>{xustop1} |
738738
<xuiend><<EOF>> {
739739
/* no UESCAPE after the quote, throw back everything */
740-
char *ident;
740+
char *ident;
741+
int identlen;
741742

742743
yyless(0);
743744

744745
BEGIN(INITIAL);
745746
if (yyextra->literallen == 0)
746747
yyerror("zero-length delimited identifier");
747748
ident = litbuf_udeescape('\\', yyscanner);
748-
if (yyextra->literallen >= NAMEDATALEN)
749-
truncate_identifier(ident, yyextra->literallen, true);
749+
identlen = strlen(ident);
750+
if (identlen >= NAMEDATALEN)
751+
truncate_identifier(ident, identlen, true);
750752
yylval->str = ident;
751753
return IDENT;
752754
}
753755
<xuiend>{xustop2} {
754756
/* found UESCAPE after the end quote */
755-
char *ident;
757+
char *ident;
758+
int identlen;
756759

757760
BEGIN(INITIAL);
758761
if (yyextra->literallen == 0)
@@ -764,8 +767,9 @@ other .
764767
yyerror("invalid Unicode escape character");
765768
}
766769
ident = litbuf_udeescape(yytext[yyleng - 2], yyscanner);
767-
if (yyextra->literallen >= NAMEDATALEN)
768-
truncate_identifier(ident, yyextra->literallen, true);
770+
identlen = strlen(ident);
771+
if (identlen >= NAMEDATALEN)
772+
truncate_identifier(ident, identlen, true);
769773
yylval->str = ident;
770774
return IDENT;
771775
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy