Check for hexadecimal literals exceeding MaxTokenLength.

This commit is contained in:
Aaron Muir Hamilton 2017-10-22 17:41:13 +00:00
parent b1eaf82cc8
commit 9028ed204d
4 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,19 @@
overlongLiteral.frag
ERROR: 0:1: '' : hexadecimal literal too long
ERROR: 0:1: '' : syntax error, unexpected INTCONSTANT
ERROR: 2 compilation errors. No code generated.
Shader version: 100
ERROR: node is still EOpNull!
0:? Linker Objects
Linked fragment stage:
ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
Shader version: 100
ERROR: node is still EOpNull!
0:? Linker Objects

View File

@ -0,0 +1 @@
0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;

View File

@ -420,7 +420,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ival = 0;
do {
if (ival <= 0x0fffffffu || (enableInt64 && ival <= 0x0fffffffffffffffull)) {
if (len < MaxTokenLength && (ival <= 0x0fffffffu || (enableInt64 && ival <= 0x0fffffffffffffffull))) {
ppToken->name[len++] = (char)ch;
if (ch >= '0' && ch <= '9') {
ii = ch - '0';
@ -433,7 +433,10 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ival = (ival << 4) | ii;
} else {
if (! AlreadyComplained) {
pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too big", "", "");
if(len < MaxTokenLength)
pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too big", "", "");
else
pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too long", "", "");
AlreadyComplained = 1;
}
ival = 0xffffffffffffffffull;

View File

@ -183,6 +183,7 @@ INSTANTIATE_TEST_CASE_P(
"matrix2.frag",
"newTexture.frag",
"Operations.frag",
"overlongLiteral.frag",
"prepost.frag",
"simpleFunctionCall.frag",
"structAssignment.frag",