Skip to content

Commit a8a46d8

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 42ec6a8 commit a8a46d8

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
@@ -620,28 +620,32 @@ other .
620620
return IDENT;
621621
}
622622
<xui>{xuistop1} {
623-
char *ident;
623+
char *ident;
624+
int identlen;
624625

625626
BEGIN(INITIAL);
626627
if (literallen == 0)
627628
yyerror("zero-length delimited identifier");
628629
ident = litbuf_udeescape('\\');
629-
if (literallen >= NAMEDATALEN)
630-
truncate_identifier(ident, literallen, true);
630+
identlen = strlen(ident);
631+
if (identlen >= NAMEDATALEN)
632+
truncate_identifier(ident, identlen, true);
631633
yylval.str = ident;
632634
/* throw back all but the quote */
633635
yyless(1);
634636
return IDENT;
635637
}
636638
<xui>{xuistop2} {
637-
char *ident;
639+
char *ident;
640+
int identlen;
638641

639642
BEGIN(INITIAL);
640643
if (literallen == 0)
641644
yyerror("zero-length delimited identifier");
642645
ident = litbuf_udeescape(yytext[yyleng - 2]);
643-
if (literallen >= NAMEDATALEN)
644-
truncate_identifier(ident, literallen, true);
646+
identlen = strlen(ident);
647+
if (identlen >= NAMEDATALEN)
648+
truncate_identifier(ident, identlen, true);
645649
yylval.str = ident;
646650
return IDENT;
647651
}

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