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

@ -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;