CMake/Source/LexerParser
Matthias Maennich 14d9a11be9 ListFileLexer: fix heap-buffer-overflow on malicious input
In case a list file contains a null terminated string that is continued
until a later space, the lexer token information got inconsistent:

e.g. an argument   "TEST\0FOOBAR"    is passed by the lexer as a token

char* = "TEST\0FOOBAR" and length 11
             ^^ note: ascii 0x00

Using strdup in cmListFileLexer leads lexer->token.text to be allocated
with size 5 and lexer->token.length to be set to 11

A subsequent call to this function with an argument of  5 < length <= 11
wrongly assumed a sufficiently sized buffer and therefore corrupted the
heap buffer. The program might crash due to this corruption.
The case "NullTerminatedArgument" is intentionally using a quite large
'rest' to increase the chance to actually hit the issue. It will reliably
crash with address sanitizer enabled though.

This fix addresses all rules where arbitrary characters are matched to
ignore \0 in order to fall through to the rule that matches an arbitrary
character as BadCharacter.

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-08-30 11:28:51 -04:00
..
.clang-tidy
.gitattributes
cmCommandArgumentLexer.cxx cmCommandArgumentLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:18:06 +02:00
cmCommandArgumentLexer.h cmCommandArgumentLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:18:06 +02:00
cmCommandArgumentLexer.in.l cmCommandArgumentLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:18:06 +02:00
cmCommandArgumentParser.cxx
cmCommandArgumentParser.y
cmCommandArgumentParserTokens.h
cmDependsJavaLexer.cxx cmDependsJavaLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:25:02 +02:00
cmDependsJavaLexer.h cmDependsJavaLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:25:02 +02:00
cmDependsJavaLexer.in.l cmDependsJavaLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:25:02 +02:00
cmDependsJavaParser.cxx
cmDependsJavaParser.y
cmDependsJavaParserTokens.h
cmExprLexer.cxx cmExprLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:31:15 +02:00
cmExprLexer.h cmExprLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:31:15 +02:00
cmExprLexer.in.l cmExprLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:31:15 +02:00
cmExprParser.cxx
cmExprParser.y
cmExprParserTokens.h
cmFortranLexer.cxx cmFortranLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:34:36 +02:00
cmFortranLexer.h cmFortranLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:34:36 +02:00
cmFortranLexer.in.l cmFortranLexer: regenerate with flex 2.6.4 (previously 2.6.1) 2017-08-29 00:34:36 +02:00
cmFortranParser.cxx
cmFortranParser.y
cmFortranParserTokens.h
cmListFileLexer.c ListFileLexer: fix heap-buffer-overflow on malicious input 2017-08-30 11:28:51 -04:00
cmListFileLexer.in.l ListFileLexer: fix heap-buffer-overflow on malicious input 2017-08-30 11:28:51 -04:00